520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
1
by brian
clean slate |
19 |
|
20 |
/**
|
|
21 |
@file
|
|
22 |
||
23 |
@brief
|
|
24 |
Handling of MySQL SQL variables
|
|
25 |
||
26 |
@details
|
|
27 |
To add a new variable, one has to do the following:
|
|
28 |
||
29 |
- Use one of the 'sys_var... classes from set_var.h or write a specific
|
|
30 |
one for the variable type.
|
|
31 |
- Define it in the 'variable definition list' in this file.
|
|
32 |
- If the variable is thread specific, add it to 'system_variables' struct.
|
|
33 |
If not, add it to mysqld.cc and an declaration in 'mysql_priv.h'
|
|
34 |
- If the variable should be changed from the command line, add a definition
|
|
35 |
of it in the my_option structure list in mysqld.cc
|
|
36 |
- Don't forget to initialize new fields in global_system_variables and
|
|
37 |
max_system_variables!
|
|
38 |
||
39 |
@todo
|
|
40 |
Add full support for the variable character_set (for 4.1)
|
|
41 |
||
42 |
@todo
|
|
43 |
When updating myisam_delay_key_write, we should do a 'flush tables'
|
|
44 |
of all MyISAM tables to ensure that they are reopen with the
|
|
45 |
new attribute.
|
|
46 |
||
47 |
@note
|
|
48 |
Be careful with var->save_result: sys_var::check() only updates
|
|
151
by Brian Aker
Ulonglong to uint64_t |
49 |
uint64_t_value; so other members of the union are garbage then; to use
|
1
by brian
clean slate |
50 |
them you must first assign a value to them (in specific ::check() for
|
51 |
example).
|
|
52 |
*/
|
|
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
53 |
|
243.1.17
by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.) |
54 |
#include <drizzled/server_includes.h> |
575.4.6
by Monty Taylor
Removed my_getwd. |
55 |
#include <drizzled/replication/mi.h> |
212.5.21
by Monty Taylor
Moved my_getopt.h |
56 |
#include <mysys/my_getopt.h> |
212.5.7
by Monty Taylor
Move thr_*h to mysys. |
57 |
#include <mysys/thr_alarm.h> |
212.4.2
by Monty Taylor
Fixed the includes in places to make the myisam header file move work. |
58 |
#include <storage/myisam/myisam.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
59 |
#include <drizzled/error.h> |
538
by Monty Taylor
Moved gettext.h into drizzled in anticipation of the new client lib. |
60 |
#include <drizzled/gettext.h> |
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
61 |
#include <drizzled/tztime.h> |
520.6.7
by Monty Taylor
Moved a bunch of crap out of common_includes. |
62 |
#include <drizzled/slave.h> |
63 |
#include <drizzled/data_home.h> |
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
64 |
#include <drizzled/set_var.h> |
65 |
#include <drizzled/session.h> |
|
66 |
#include <drizzled/sql_base.h> |
|
670.2.4
by Monty Taylor
Removed more stuff from the headers. |
67 |
#include <drizzled/lock.h> |
642.1.16
by Lee
header file clean up |
68 |
#include <drizzled/item/uint.h> |
642.1.20
by Lee
header file clean up |
69 |
#include <drizzled/item/null.h> |
670.1.22
by Monty Taylor
Merged from Lee. |
70 |
#include <drizzled/item/float.h> |
1
by brian
clean slate |
71 |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
72 |
extern const CHARSET_INFO *character_set_filesystem; |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
73 |
extern I_List<NAMED_LIST> key_caches; |
629.2.7
by Monty Taylor
Fixed a couple of memory buffer size issues. |
74 |
extern size_t my_thread_stack_size; |
1
by brian
clean slate |
75 |
|
76 |
static DYNAMIC_ARRAY fixed_show_vars; |
|
77 |
static HASH system_variable_hash; |
|
670.2.4
by Monty Taylor
Removed more stuff from the headers. |
78 |
extern char *opt_drizzle_tmpdir; |
1
by brian
clean slate |
79 |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
80 |
const char *bool_type_names[]= { "OFF", "ON", NULL }; |
1
by brian
clean slate |
81 |
TYPELIB bool_typelib= |
82 |
{
|
|
83 |
array_elements(bool_type_names)-1, "", bool_type_names, NULL |
|
84 |
};
|
|
85 |
||
461
by Monty Taylor
Removed NullS. bu-bye. |
86 |
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL }; |
1
by brian
clean slate |
87 |
TYPELIB delay_key_write_typelib= |
88 |
{
|
|
89 |
array_elements(delay_key_write_type_names)-1, "", |
|
90 |
delay_key_write_type_names, NULL |
|
91 |
};
|
|
92 |
||
93 |
const char *slave_exec_mode_names[]= |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
94 |
{ "STRICT", "IDEMPOTENT", NULL }; |
1
by brian
clean slate |
95 |
static const unsigned int slave_exec_mode_names_len[]= |
96 |
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 }; |
|
97 |
TYPELIB slave_exec_mode_typelib= |
|
98 |
{
|
|
99 |
array_elements(slave_exec_mode_names)-1, "", |
|
100 |
slave_exec_mode_names, (unsigned int *) slave_exec_mode_names_len |
|
101 |
};
|
|
102 |
||
520.1.21
by Brian Aker
THD -> Session rename |
103 |
static bool sys_update_init_connect(Session*, set_var*); |
104 |
static void sys_default_init_connect(Session*, enum_var_type type); |
|
105 |
static bool sys_update_init_slave(Session*, set_var*); |
|
106 |
static void sys_default_init_slave(Session*, enum_var_type type); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
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_log_update(Session *session, set_var *var); |
|
110 |
static int check_pseudo_thread_id(Session *session, set_var *var); |
|
111 |
static int check_tx_isolation(Session *session, set_var *var); |
|
112 |
static void fix_tx_isolation(Session *session, enum_var_type type); |
|
113 |
static int check_completion_type(Session *session, set_var *var); |
|
114 |
static void fix_completion_type(Session *session, enum_var_type type); |
|
115 |
static void fix_net_read_timeout(Session *session, enum_var_type type); |
|
116 |
static void fix_net_write_timeout(Session *session, enum_var_type type); |
|
117 |
static void fix_net_retry_count(Session *session, enum_var_type type); |
|
118 |
static void fix_max_join_size(Session *session, enum_var_type type); |
|
119 |
static void fix_myisam_max_sort_file_size(Session *session, enum_var_type type); |
|
120 |
static void fix_max_binlog_size(Session *session, enum_var_type type); |
|
121 |
static void fix_max_relay_log_size(Session *session, enum_var_type type); |
|
122 |
static void fix_max_connections(Session *session, enum_var_type type); |
|
123 |
static void fix_session_mem_root(Session *session, enum_var_type type); |
|
124 |
static void fix_trans_mem_root(Session *session, enum_var_type type); |
|
125 |
static void fix_server_id(Session *session, enum_var_type type); |
|
520.1.21
by Brian Aker
THD -> Session rename |
126 |
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
127 |
static bool get_unsigned(Session *session, set_var *var); |
128 |
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
|
152
by Brian Aker
longlong replacement |
129 |
const char *name, int64_t val); |
482
by Brian Aker
Remove uint. |
130 |
static KEY_CACHE *create_key_cache(const char *name, uint32_t length); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
131 |
static unsigned char *get_error_count(Session *session); |
132 |
static unsigned char *get_warning_count(Session *session); |
|
133 |
static unsigned char *get_tmpdir(Session *session); |
|
1
by brian
clean slate |
134 |
|
135 |
/*
|
|
136 |
Variable definition list
|
|
137 |
||
138 |
These are variables that can be set from the command line, in
|
|
139 |
alphabetic order.
|
|
140 |
||
141 |
The variables are linked into the list. A variable is added to
|
|
142 |
it in the constructor (see sys_var class for details).
|
|
143 |
*/
|
|
144 |
||
145 |
static sys_var_chain vars = { NULL, NULL }; |
|
146 |
||
616
by Brian Aker
ulong fixes. |
147 |
static sys_var_session_uint32_t |
1
by brian
clean slate |
148 |
sys_auto_increment_increment(&vars, "auto_increment_increment", |
149 |
&SV::auto_increment_increment, NULL, NULL, |
|
150 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
616
by Brian Aker
ulong fixes. |
151 |
static sys_var_session_uint32_t |
1
by brian
clean slate |
152 |
sys_auto_increment_offset(&vars, "auto_increment_offset", |
153 |
&SV::auto_increment_offset, NULL, NULL, |
|
154 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
155 |
||
575.4.1
by ysano
Rename mysql to drizzle. |
156 |
static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home); |
1
by brian
clean slate |
157 |
static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size", |
622
by Brian Aker
More ulong work. |
158 |
&binlog_cache_size); |
619
by Brian Aker
Removed ulong methods from vars. |
159 |
static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size", |
160 |
&SV::bulk_insert_buff_size); |
|
161 |
static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type", |
|
162 |
&SV::completion_type, |
|
163 |
check_completion_type, |
|
164 |
fix_completion_type); |
|
1
by brian
clean slate |
165 |
static sys_var_collation_sv |
166 |
sys_collation_database(&vars, "collation_database", &SV::collation_database, |
|
167 |
&default_charset_info, |
|
168 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
169 |
static sys_var_collation_sv |
|
170 |
sys_collation_server(&vars, "collation_server", &SV::collation_server, |
|
171 |
&default_charset_info, |
|
172 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
173 |
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout", |
|
622
by Brian Aker
More ulong work. |
174 |
&connect_timeout); |
575.4.1
by ysano
Rename mysql to drizzle. |
175 |
static sys_var_const_str sys_datadir(&vars, "datadir", drizzle_real_data_home); |
1
by brian
clean slate |
176 |
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write", |
177 |
&delay_key_write_options, |
|
178 |
&delay_key_write_typelib, |
|
179 |
fix_delay_key_write); |
|
180 |
||
181 |
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days", |
|
622
by Brian Aker
More ulong work. |
182 |
&expire_logs_days); |
1
by brian
clean slate |
183 |
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush); |
184 |
sys_var_str sys_init_connect(&vars, "init_connect", 0, |
|
185 |
sys_update_init_connect, |
|
186 |
sys_default_init_connect,0); |
|
187 |
sys_var_str sys_init_slave(&vars, "init_slave", 0, |
|
188 |
sys_update_init_slave, |
|
189 |
sys_default_init_slave,0); |
|
616
by Brian Aker
ulong fixes. |
190 |
static sys_var_session_uint32_t sys_interactive_timeout(&vars, "interactive_timeout", |
191 |
&SV::net_interactive_timeout); |
|
192 |
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size", |
|
193 |
&SV::join_buff_size); |
|
1
by brian
clean slate |
194 |
static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size"); |
195 |
static sys_var_key_cache_long sys_key_cache_block_size(&vars, "key_cache_block_size", |
|
616
by Brian Aker
ulong fixes. |
196 |
offsetof(KEY_CACHE, |
197 |
param_block_size)); |
|
1
by brian
clean slate |
198 |
static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_division_limit", |
616
by Brian Aker
ulong fixes. |
199 |
offsetof(KEY_CACHE, |
200 |
param_division_limit)); |
|
1
by brian
clean slate |
201 |
static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold", |
616
by Brian Aker
ulong fixes. |
202 |
offsetof(KEY_CACHE, |
203 |
param_age_threshold)); |
|
1
by brian
clean slate |
204 |
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile", |
616
by Brian Aker
ulong fixes. |
205 |
&opt_local_infile); |
206 |
static sys_var_session_uint32_t sys_max_allowed_packet(&vars, "max_allowed_packet", |
|
207 |
&SV::max_allowed_packet); |
|
1
by brian
clean slate |
208 |
static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size", |
616
by Brian Aker
ulong fixes. |
209 |
&max_binlog_cache_size); |
1
by brian
clean slate |
210 |
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size", |
616
by Brian Aker
ulong fixes. |
211 |
&max_binlog_size, |
1
by brian
clean slate |
212 |
fix_max_binlog_size); |
213 |
static sys_var_long_ptr sys_max_connections(&vars, "max_connections", |
|
616
by Brian Aker
ulong fixes. |
214 |
&max_connections, |
1
by brian
clean slate |
215 |
fix_max_connections); |
216 |
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors", |
|
616
by Brian Aker
ulong fixes. |
217 |
&max_connect_errors); |
218 |
static sys_var_session_uint64_t sys_max_error_count(&vars, "max_error_count", |
|
219 |
&SV::max_error_count); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
220 |
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size", |
616
by Brian Aker
ulong fixes. |
221 |
&SV::max_heap_table_size); |
555
by Monty
Fixed 32-bit issues. |
222 |
static sys_var_session_uint64_t sys_pseudo_thread_id(&vars, "pseudo_thread_id", |
1
by brian
clean slate |
223 |
&SV::pseudo_thread_id, |
555
by Monty
Fixed 32-bit issues. |
224 |
0, check_pseudo_thread_id, |
1
by brian
clean slate |
225 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
226 |
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size", |
617
by Brian Aker
ulong fixes |
227 |
&SV::max_join_size, |
228 |
fix_max_join_size); |
|
229 |
static sys_var_session_uint64_t sys_max_seeks_for_key(&vars, "max_seeks_for_key", |
|
615
by Brian Aker
Added 32bit system variable support |
230 |
&SV::max_seeks_for_key); |
231 |
static sys_var_session_uint64_t sys_max_length_for_sort_data(&vars, "max_length_for_sort_data", |
|
232 |
&SV::max_length_for_sort_data); |
|
1
by brian
clean slate |
233 |
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size", |
234 |
&max_relay_log_size, |
|
235 |
fix_max_relay_log_size); |
|
617
by Brian Aker
ulong fixes |
236 |
static sys_var_session_uint64_t sys_max_sort_length(&vars, "max_sort_length", |
615
by Brian Aker
Added 32bit system variable support |
237 |
&SV::max_sort_length); |
238 |
static sys_var_session_uint64_t sys_max_tmp_tables(&vars, "max_tmp_tables", |
|
239 |
&SV::max_tmp_tables); |
|
1
by brian
clean slate |
240 |
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count", |
622.1.1
by Brian Aker
32bit fixes around vars |
241 |
&max_write_lock_count); |
619
by Brian Aker
Removed ulong methods from vars. |
242 |
static sys_var_session_uint64_t sys_min_examined_row_limit(&vars, "min_examined_row_limit", |
243 |
&SV::min_examined_row_limit); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
244 |
static sys_var_session_uint64_t sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1); |
617
by Brian Aker
ulong fixes |
245 |
static sys_var_session_uint32_t sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
246 |
static sys_var_session_size_t sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size); |
1
by brian
clean slate |
247 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
248 |
static sys_var_session_enum sys_myisam_stats_method(&vars, "myisam_stats_method", |
617
by Brian Aker
ulong fixes |
249 |
&SV::myisam_stats_method, |
250 |
&myisam_stats_method_typelib, |
|
251 |
NULL); |
|
616
by Brian Aker
ulong fixes. |
252 |
static sys_var_session_uint32_t sys_net_buffer_length(&vars, "net_buffer_length", |
253 |
&SV::net_buffer_length); |
|
254 |
static sys_var_session_uint32_t sys_net_read_timeout(&vars, "net_read_timeout", |
|
255 |
&SV::net_read_timeout, |
|
256 |
0, fix_net_read_timeout); |
|
257 |
static sys_var_session_uint32_t sys_net_write_timeout(&vars, "net_write_timeout", |
|
258 |
&SV::net_write_timeout, |
|
259 |
0, fix_net_write_timeout); |
|
260 |
static sys_var_session_uint32_t sys_net_retry_count(&vars, "net_retry_count", |
|
261 |
&SV::net_retry_count, |
|
262 |
0, fix_net_retry_count); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
263 |
static sys_var_session_bool sys_new_mode(&vars, "new", &SV::new_mode); |
1
by brian
clean slate |
264 |
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old", |
616
by Brian Aker
ulong fixes. |
265 |
&global_system_variables.old_mode); |
1
by brian
clean slate |
266 |
/* these two cannot be static */
|
619
by Brian Aker
Removed ulong methods from vars. |
267 |
sys_var_session_bool sys_old_alter_table(&vars, "old_alter_table", |
268 |
&SV::old_alter_table); |
|
269 |
static sys_var_session_bool sys_optimizer_prune_level(&vars, "optimizer_prune_level", |
|
270 |
&SV::optimizer_prune_level); |
|
271 |
static sys_var_session_uint32_t sys_optimizer_search_depth(&vars, "optimizer_search_depth", |
|
272 |
&SV::optimizer_search_depth); |
|
1
by brian
clean slate |
273 |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
274 |
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL}; |
1
by brian
clean slate |
275 |
TYPELIB optimizer_use_mrr_typelib= { |
276 |
array_elements(optimizer_use_mrr_names) - 1, "", |
|
277 |
optimizer_use_mrr_names, NULL |
|
278 |
};
|
|
279 |
||
617
by Brian Aker
ulong fixes |
280 |
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr", |
281 |
&SV::optimizer_use_mrr, |
|
282 |
&optimizer_use_mrr_typelib, |
|
283 |
NULL); |
|
1
by brian
clean slate |
284 |
|
619
by Brian Aker
Removed ulong methods from vars. |
285 |
static sys_var_session_uint64_t sys_preload_buff_size(&vars, "preload_buffer_size", |
286 |
&SV::preload_buff_size); |
|
287 |
static sys_var_session_uint32_t sys_read_buff_size(&vars, "read_buffer_size", |
|
288 |
&SV::read_buff_size); |
|
289 |
static sys_var_session_uint32_t sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size", |
|
290 |
&SV::read_rnd_buff_size); |
|
291 |
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment", |
|
292 |
&SV::div_precincrement); |
|
1
by brian
clean slate |
293 |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
294 |
static sys_var_session_size_t sys_range_alloc_block_size(&vars, "range_alloc_block_size", |
615
by Brian Aker
Added 32bit system variable support |
295 |
&SV::range_alloc_block_size); |
296 |
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size", |
|
297 |
&SV::query_alloc_block_size, |
|
617
by Brian Aker
ulong fixes |
298 |
false, fix_session_mem_root); |
615
by Brian Aker
Added 32bit system variable support |
299 |
static sys_var_session_uint32_t sys_query_prealloc_size(&vars, "query_prealloc_size", |
300 |
&SV::query_prealloc_size, |
|
617
by Brian Aker
ulong fixes |
301 |
false, fix_session_mem_root); |
302 |
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir); |
|
615
by Brian Aker
Added 32bit system variable support |
303 |
static sys_var_session_uint32_t sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size", |
304 |
&SV::trans_alloc_block_size, |
|
617
by Brian Aker
ulong fixes |
305 |
false, fix_trans_mem_root); |
615
by Brian Aker
Added 32bit system variable support |
306 |
static sys_var_session_uint32_t sys_trans_prealloc_size(&vars, "transaction_prealloc_size", |
307 |
&SV::trans_prealloc_size, |
|
617
by Brian Aker
ulong fixes |
308 |
false, fix_trans_mem_root); |
1
by brian
clean slate |
309 |
|
310 |
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv", |
|
311 |
&opt_secure_file_priv); |
|
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
312 |
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id, |
313 |
fix_server_id); |
|
314 |
||
1
by brian
clean slate |
315 |
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol", |
316 |
&opt_slave_compressed_protocol); |
|
317 |
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching", |
|
318 |
&slave_allow_batching); |
|
319 |
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time", |
|
619
by Brian Aker
Removed ulong methods from vars. |
320 |
&slow_launch_time); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
321 |
static sys_var_session_size_t sys_sort_buffer(&vars, "sort_buffer_size", |
619
by Brian Aker
Removed ulong methods from vars. |
322 |
&SV::sortbuff_size); |
1
by brian
clean slate |
323 |
/*
|
324 |
sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
|
|
325 |
even though it is written to the binlog, the slave ignores the
|
|
326 |
MODE_NO_DIR_IN_CREATE variable, so slave's value differs from
|
|
327 |
master's (see log_event.cc: Query_log_event::do_apply_event()).
|
|
328 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
329 |
static sys_var_session_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch", |
617
by Brian Aker
ulong fixes |
330 |
&SV::optimizer_switch); |
1
by brian
clean slate |
331 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
332 |
static sys_var_session_storage_engine sys_storage_engine(&vars, "storage_engine", |
1
by brian
clean slate |
333 |
&SV::table_plugin); |
334 |
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone", |
|
335 |
system_time_zone); |
|
336 |
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache", |
|
337 |
&table_def_size); |
|
338 |
static sys_var_long_ptr sys_table_cache_size(&vars, "table_open_cache", |
|
339 |
&table_cache_size); |
|
340 |
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout", |
|
341 |
&table_lock_wait_timeout); |
|
342 |
sys_var_long_ptr sys_thread_pool_size(&vars, "thread_pool_size", |
|
622
by Brian Aker
More ulong work. |
343 |
&thread_pool_size); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
344 |
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation", |
617
by Brian Aker
ulong fixes |
345 |
&SV::tx_isolation, |
346 |
&tx_isolation_typelib, |
|
347 |
fix_tx_isolation, |
|
348 |
check_tx_isolation); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
349 |
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size", |
1
by brian
clean slate |
350 |
&SV::tmp_table_size); |
147
by Brian Aker
More my_bool conversion. This time the set_var class. |
351 |
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes); |
1
by brian
clean slate |
352 |
static sys_var_const_str sys_version(&vars, "version", server_version); |
353 |
static sys_var_const_str sys_version_comment(&vars, "version_comment", |
|
546
by Monty Taylor
Cleaned up version.h. (And by cleaned, I mean removed) |
354 |
COMPILATION_COMMENT); |
1
by brian
clean slate |
355 |
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine", |
356 |
MACHINE_TYPE); |
|
357 |
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os", |
|
358 |
SYSTEM_TYPE); |
|
616
by Brian Aker
ulong fixes. |
359 |
static sys_var_session_uint32_t sys_net_wait_timeout(&vars, "wait_timeout", |
360 |
&SV::net_wait_timeout); |
|
1
by brian
clean slate |
361 |
|
362 |
/* Condition pushdown to storage engine */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
363 |
static sys_var_session_bool |
1
by brian
clean slate |
364 |
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown", |
365 |
&SV::engine_condition_pushdown); |
|
366 |
||
367 |
/* Time/date/datetime formats */
|
|
368 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
369 |
static sys_var_session_date_time_format sys_time_format(&vars, "time_format", |
1
by brian
clean slate |
370 |
&SV::time_format, |
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
371 |
DRIZZLE_TIMESTAMP_TIME); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
372 |
static sys_var_session_date_time_format sys_date_format(&vars, "date_format", |
1
by brian
clean slate |
373 |
&SV::date_format, |
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
374 |
DRIZZLE_TIMESTAMP_DATE); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
375 |
static sys_var_session_date_time_format sys_datetime_format(&vars, "datetime_format", |
1
by brian
clean slate |
376 |
&SV::datetime_format, |
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
377 |
DRIZZLE_TIMESTAMP_DATETIME); |
1
by brian
clean slate |
378 |
|
520.1.21
by Brian Aker
THD -> Session rename |
379 |
/* Variables that are bits in Session */
|
1
by brian
clean slate |
380 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
381 |
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0, |
1
by brian
clean slate |
382 |
set_option_autocommit, |
383 |
OPTION_NOT_AUTOCOMMIT, |
|
384 |
1); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
385 |
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0, |
1
by brian
clean slate |
386 |
set_option_bit, |
387 |
OPTION_BIG_SELECTS); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
388 |
static sys_var_session_bit sys_log_binlog(&vars, "sql_log_bin", |
1
by brian
clean slate |
389 |
check_log_update, |
390 |
set_option_bit, |
|
391 |
OPTION_BIN_LOG); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
392 |
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0, |
1
by brian
clean slate |
393 |
set_option_bit, |
394 |
OPTION_WARNINGS); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
395 |
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0, |
1
by brian
clean slate |
396 |
set_option_bit, |
397 |
OPTION_SQL_NOTES); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
398 |
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0, |
1
by brian
clean slate |
399 |
set_option_bit, |
400 |
OPTION_SAFE_UPDATES); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
401 |
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0, |
1
by brian
clean slate |
402 |
set_option_bit, |
403 |
OPTION_BUFFER_RESULT); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
404 |
static sys_var_session_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0, |
1
by brian
clean slate |
405 |
set_option_bit, |
406 |
OPTION_QUOTE_SHOW_CREATE); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
407 |
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0, |
1
by brian
clean slate |
408 |
set_option_bit, |
409 |
OPTION_NO_FOREIGN_KEY_CHECKS, |
|
410 |
1, sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
411 |
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0, |
1
by brian
clean slate |
412 |
set_option_bit, |
413 |
OPTION_RELAXED_UNIQUE_CHECKS, |
|
414 |
1, |
|
415 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
416 |
/* Local state variables */
|
|
417 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
418 |
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit", |
1
by brian
clean slate |
419 |
&SV::select_limit); |
420 |
static sys_var_timestamp sys_timestamp(&vars, "timestamp", |
|
421 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
422 |
static sys_var_last_insert_id |
|
423 |
sys_last_insert_id(&vars, "last_insert_id", |
|
424 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
425 |
/*
|
|
426 |
identity is an alias for last_insert_id(), so that we are compatible
|
|
427 |
with Sybase
|
|
428 |
*/
|
|
429 |
static sys_var_last_insert_id |
|
430 |
sys_identity(&vars, "identity", sys_var::SESSION_VARIABLE_IN_BINLOG); |
|
431 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
432 |
static sys_var_session_lc_time_names |
1
by brian
clean slate |
433 |
sys_lc_time_names(&vars, "lc_time_names", sys_var::SESSION_VARIABLE_IN_BINLOG); |
434 |
||
435 |
/*
|
|
436 |
insert_id should *not* be marked as written to the binlog (i.e., it
|
|
437 |
should *not* have binlog_status==SESSION_VARIABLE_IN_BINLOG),
|
|
438 |
because we want any statement that refers to insert_id explicitly to
|
|
439 |
be unsafe. (By "explicitly", we mean using @@session.insert_id,
|
|
440 |
whereas insert_id is used "implicitly" when NULL value is inserted
|
|
441 |
into an auto_increment column).
|
|
442 |
||
443 |
We want statements referring explicitly to @@session.insert_id to be
|
|
444 |
unsafe, because insert_id is modified internally by the slave sql
|
|
445 |
thread when NULL values are inserted in an AUTO_INCREMENT column.
|
|
446 |
This modification interfers with the value of the
|
|
447 |
@@session.insert_id variable if @@session.insert_id is referred
|
|
448 |
explicitly by an insert statement (as is seen by executing "SET
|
|
449 |
@@session.insert_id=0; CREATE TABLE t (a INT, b INT KEY
|
|
450 |
AUTO_INCREMENT); INSERT INTO t(a) VALUES (@@session.insert_id);" in
|
|
451 |
statement-based logging mode: t will be different on master and
|
|
452 |
slave).
|
|
453 |
*/
|
|
626
by Brian Aker
More of the same (ulong/64) |
454 |
static sys_var_readonly sys_error_count(&vars, "error_count", |
455 |
OPT_SESSION, |
|
456 |
SHOW_LONG, |
|
457 |
get_error_count); |
|
458 |
static sys_var_readonly sys_warning_count(&vars, "warning_count", |
|
459 |
OPT_SESSION, |
|
460 |
SHOW_LONG, |
|
461 |
get_warning_count); |
|
1
by brian
clean slate |
462 |
|
615
by Brian Aker
Added 32bit system variable support |
463 |
static sys_var_session_uint32_t sys_default_week_format(&vars, "default_week_format", |
464 |
&SV::default_week_format); |
|
1
by brian
clean slate |
465 |
|
617
by Brian Aker
ulong fixes |
466 |
sys_var_session_uint64_t sys_group_concat_max_len(&vars, "group_concat_max_len", |
467 |
&SV::group_concat_max_len); |
|
1
by brian
clean slate |
468 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
469 |
sys_var_session_time_zone sys_time_zone(&vars, "time_zone", |
1
by brian
clean slate |
470 |
sys_var::SESSION_VARIABLE_IN_BINLOG); |
471 |
||
472 |
/* Global read-only variable containing hostname */
|
|
473 |
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname); |
|
474 |
||
475 |
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host); |
|
476 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
477 |
sys_var_session_bool sys_keep_files_on_create(&vars, "keep_files_on_create", |
1
by brian
clean slate |
478 |
&SV::keep_files_on_create); |
479 |
/* Read only variables */
|
|
480 |
||
481 |
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink); |
|
482 |
/*
|
|
483 |
Additional variables (not derived from sys_var class, not accessible as
|
|
484 |
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
|
|
485 |
maintenance - SHOW VARIABLES will sort its output.
|
|
486 |
TODO: remove this list completely
|
|
487 |
*/
|
|
488 |
||
489 |
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
|
|
490 |
static SHOW_VAR fixed_vars[]= { |
|
626
by Brian Aker
More of the same (ulong/64) |
491 |
{"back_log", (char*) &back_log, SHOW_INT}, |
1
by brian
clean slate |
492 |
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR}, |
493 |
{"language", language, SHOW_CHAR}, |
|
494 |
#ifdef HAVE_MLOCKALL
|
|
495 |
{"locked_in_memory", (char*) &locked_in_memory, SHOW_MY_BOOL}, |
|
496 |
#endif
|
|
497 |
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL}, |
|
498 |
{"log_error", (char*) log_error_file, SHOW_CHAR}, |
|
499 |
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR}, |
|
626
by Brian Aker
More of the same (ulong/64) |
500 |
{"open_files_limit", (char*) &open_files_limit, SHOW_LONGLONG}, |
1
by brian
clean slate |
501 |
{"pid_file", (char*) pidfile_name, SHOW_CHAR}, |
502 |
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR}, |
|
574.2.1
by ysano
Rename mysql to drizzle. |
503 |
{"port", (char*) &drizzled_port, SHOW_INT}, |
1
by brian
clean slate |
504 |
{"protocol_version", (char*) &protocol_version, SHOW_INT}, |
626
by Brian Aker
More of the same (ulong/64) |
505 |
{"thread_stack", (char*) &my_thread_stack_size, SHOW_INT}, |
1
by brian
clean slate |
506 |
};
|
507 |
||
508 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
509 |
bool sys_var::check(Session *, set_var *var) |
1
by brian
clean slate |
510 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
511 |
var->save_result.uint64_t_value= var->value->val_int(); |
1
by brian
clean slate |
512 |
return 0; |
513 |
}
|
|
514 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
515 |
bool sys_var_str::check(Session *session, set_var *var) |
1
by brian
clean slate |
516 |
{
|
517 |
int res; |
|
518 |
if (!check_func) |
|
519 |
return 0; |
|
520 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
521 |
if ((res=(*check_func)(session, var)) < 0) |
1
by brian
clean slate |
522 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), |
523 |
name, var->value->str_value.ptr()); |
|
524 |
return res; |
|
525 |
}
|
|
526 |
||
527 |
/*
|
|
528 |
Functions to check and update variables
|
|
529 |
*/
|
|
530 |
||
531 |
||
532 |
/*
|
|
533 |
Update variables 'init_connect, init_slave'.
|
|
534 |
||
535 |
In case of 'DEFAULT' value
|
|
536 |
(for example: 'set GLOBAL init_connect=DEFAULT')
|
|
537 |
'var' parameter is NULL pointer.
|
|
538 |
*/
|
|
539 |
||
658
by Brian Aker
Part removal of my_pthread.h |
540 |
bool update_sys_var_str(sys_var_str *var_str, pthread_rwlock_t *var_mutex, |
656.1.34
by Monty Taylor
Got closer... |
541 |
set_var *var) |
1
by brian
clean slate |
542 |
{
|
543 |
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0); |
|
482
by Brian Aker
Remove uint. |
544 |
uint32_t new_length= (var ? var->value->str_value.length() : 0); |
1
by brian
clean slate |
545 |
if (!old_value) |
546 |
old_value= (char*) ""; |
|
656.1.34
by Monty Taylor
Got closer... |
547 |
res= (char *)malloc(new_length + 1); |
656.1.32
by Monty Taylor
Removed strndup. (doesn't exist on solaris) |
548 |
if (res == NULL) |
1
by brian
clean slate |
549 |
return 1; |
656.1.34
by Monty Taylor
Got closer... |
550 |
memcpy(res, old_value, new_length); |
551 |
res[new_length]= 0; |
|
656.1.32
by Monty Taylor
Removed strndup. (doesn't exist on solaris) |
552 |
|
1
by brian
clean slate |
553 |
/*
|
554 |
Replace the old value in such a way that the any thread using
|
|
555 |
the value will work.
|
|
556 |
*/
|
|
658
by Brian Aker
Part removal of my_pthread.h |
557 |
pthread_rwlock_wrlock(var_mutex); |
1
by brian
clean slate |
558 |
old_value= var_str->value; |
559 |
var_str->value= res; |
|
560 |
var_str->value_length= new_length; |
|
658
by Brian Aker
Part removal of my_pthread.h |
561 |
pthread_rwlock_unlock(var_mutex); |
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
562 |
free(old_value); |
1
by brian
clean slate |
563 |
return 0; |
564 |
}
|
|
565 |
||
566 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
567 |
static bool sys_update_init_connect(Session *, set_var *var) |
1
by brian
clean slate |
568 |
{
|
569 |
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var); |
|
570 |
}
|
|
571 |
||
572 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
573 |
static void sys_default_init_connect(Session *, enum_var_type) |
1
by brian
clean slate |
574 |
{
|
575 |
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0); |
|
576 |
}
|
|
577 |
||
578 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
579 |
static bool sys_update_init_slave(Session *, set_var *var) |
1
by brian
clean slate |
580 |
{
|
581 |
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var); |
|
582 |
}
|
|
583 |
||
584 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
585 |
static void sys_default_init_slave(Session *, enum_var_type) |
1
by brian
clean slate |
586 |
{
|
587 |
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0); |
|
588 |
}
|
|
589 |
||
590 |
||
591 |
static void |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
592 |
fix_myisam_max_sort_file_size(Session *, enum_var_type) |
1
by brian
clean slate |
593 |
{
|
594 |
myisam_max_temp_length= |
|
595 |
(my_off_t) global_system_variables.myisam_max_sort_file_size; |
|
596 |
}
|
|
597 |
||
598 |
/**
|
|
599 |
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
|
|
600 |
*/
|
|
601 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
602 |
static void fix_max_join_size(Session *session, enum_var_type type) |
1
by brian
clean slate |
603 |
{
|
604 |
if (type != OPT_GLOBAL) |
|
605 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
606 |
if (session->variables.max_join_size == HA_POS_ERROR) |
607 |
session->options|= OPTION_BIG_SELECTS; |
|
1
by brian
clean slate |
608 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
609 |
session->options&= ~OPTION_BIG_SELECTS; |
1
by brian
clean slate |
610 |
}
|
611 |
}
|
|
612 |
||
613 |
||
614 |
/**
|
|
615 |
Can't change the 'next' tx_isolation while we are already in
|
|
616 |
a transaction
|
|
617 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
618 |
static int check_tx_isolation(Session *session, set_var *var) |
1
by brian
clean slate |
619 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
620 |
if (var->type == OPT_DEFAULT && (session->server_status & SERVER_STATUS_IN_TRANS)) |
1
by brian
clean slate |
621 |
{
|
622 |
my_error(ER_CANT_CHANGE_TX_ISOLATION, MYF(0)); |
|
623 |
return 1; |
|
624 |
}
|
|
625 |
return 0; |
|
626 |
}
|
|
627 |
||
628 |
/*
|
|
629 |
If one doesn't use the SESSION modifier, the isolation level
|
|
630 |
is only active for the next command.
|
|
631 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
632 |
static void fix_tx_isolation(Session *session, enum_var_type type) |
1
by brian
clean slate |
633 |
{
|
634 |
if (type == OPT_SESSION) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
635 |
session->session_tx_isolation= ((enum_tx_isolation) |
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
636 |
session->variables.tx_isolation); |
1
by brian
clean slate |
637 |
}
|
638 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
639 |
static void fix_completion_type(Session *, enum_var_type) {} |
1
by brian
clean slate |
640 |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
641 |
static int check_completion_type(Session *, set_var *var) |
1
by brian
clean slate |
642 |
{
|
152
by Brian Aker
longlong replacement |
643 |
int64_t val= var->value->val_int(); |
1
by brian
clean slate |
644 |
if (val < 0 || val > 2) |
645 |
{
|
|
646 |
char buf[64]; |
|
647 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, llstr(val, buf)); |
|
648 |
return 1; |
|
649 |
}
|
|
650 |
return 0; |
|
651 |
}
|
|
652 |
||
653 |
||
654 |
/*
|
|
655 |
If we are changing the thread variable, we have to copy it to NET too
|
|
656 |
*/
|
|
657 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
658 |
static void fix_net_read_timeout(Session *session, enum_var_type type) |
659 |
{
|
|
660 |
if (type != OPT_GLOBAL) |
|
661 |
my_net_set_read_timeout(&session->net, session->variables.net_read_timeout); |
|
662 |
}
|
|
663 |
||
664 |
||
665 |
static void fix_net_write_timeout(Session *session, enum_var_type type) |
|
666 |
{
|
|
667 |
if (type != OPT_GLOBAL) |
|
668 |
my_net_set_write_timeout(&session->net, session->variables.net_write_timeout); |
|
669 |
}
|
|
670 |
||
671 |
static void fix_net_retry_count(Session *session, enum_var_type type) |
|
672 |
{
|
|
673 |
if (type != OPT_GLOBAL) |
|
674 |
session->net.retry_count=session->variables.net_retry_count; |
|
675 |
}
|
|
676 |
||
677 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
678 |
extern void fix_delay_key_write(Session *, enum_var_type) |
1
by brian
clean slate |
679 |
{
|
680 |
switch ((enum_delay_key_write) delay_key_write_options) { |
|
681 |
case DELAY_KEY_WRITE_NONE: |
|
682 |
myisam_delay_key_write=0; |
|
683 |
break; |
|
684 |
case DELAY_KEY_WRITE_ON: |
|
685 |
myisam_delay_key_write=1; |
|
686 |
break; |
|
687 |
case DELAY_KEY_WRITE_ALL: |
|
688 |
myisam_delay_key_write=1; |
|
689 |
ha_open_options|= HA_OPEN_DELAY_KEY_WRITE; |
|
690 |
break; |
|
691 |
}
|
|
692 |
}
|
|
693 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
694 |
void fix_slave_exec_mode(enum_var_type) |
1
by brian
clean slate |
695 |
{
|
696 |
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 && |
|
697 |
bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1) |
|
698 |
{
|
|
338
by Monty Taylor
Tagged more strings. |
699 |
sql_print_error(_("Ambiguous slave modes combination." |
700 |
" STRICT will be used")); |
|
1
by brian
clean slate |
701 |
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT); |
702 |
}
|
|
703 |
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0) |
|
704 |
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT); |
|
705 |
}
|
|
706 |
||
707 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
708 |
static void fix_max_binlog_size(Session *, enum_var_type) |
1
by brian
clean slate |
709 |
{
|
586.1.1
by Yoshinori Sano
Rename mysql to drizzle, specifically mysql_bin_log to drizzle_bin_log. |
710 |
drizzle_bin_log.set_max_size(max_binlog_size); |
1
by brian
clean slate |
711 |
if (!max_relay_log_size) |
712 |
active_mi->rli.relay_log.set_max_size(max_binlog_size); |
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
713 |
return; |
1
by brian
clean slate |
714 |
}
|
715 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
716 |
static void fix_max_relay_log_size(Session *, enum_var_type) |
1
by brian
clean slate |
717 |
{
|
718 |
active_mi->rli.relay_log.set_max_size(max_relay_log_size ? |
|
719 |
max_relay_log_size: max_binlog_size); |
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
720 |
return; |
1
by brian
clean slate |
721 |
}
|
722 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
723 |
static void fix_max_connections(Session *, enum_var_type) |
1
by brian
clean slate |
724 |
{
|
725 |
resize_thr_alarm(max_connections + 10); |
|
726 |
}
|
|
727 |
||
728 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
729 |
static void fix_session_mem_root(Session *session, enum_var_type type) |
730 |
{
|
|
731 |
if (type != OPT_GLOBAL) |
|
732 |
reset_root_defaults(session->mem_root, |
|
733 |
session->variables.query_alloc_block_size, |
|
734 |
session->variables.query_prealloc_size); |
|
735 |
}
|
|
736 |
||
737 |
||
738 |
static void fix_trans_mem_root(Session *session, enum_var_type type) |
|
739 |
{
|
|
740 |
if (type != OPT_GLOBAL) |
|
741 |
reset_root_defaults(&session->transaction.mem_root, |
|
742 |
session->variables.trans_alloc_block_size, |
|
743 |
session->variables.trans_prealloc_size); |
|
744 |
}
|
|
745 |
||
746 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
747 |
static void fix_server_id(Session *session, enum_var_type) |
1
by brian
clean slate |
748 |
{
|
749 |
server_id_supplied = 1; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
750 |
session->server_id= server_id; |
1
by brian
clean slate |
751 |
}
|
752 |
||
753 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
754 |
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
152
by Brian Aker
longlong replacement |
755 |
const char *name, int64_t val) |
1
by brian
clean slate |
756 |
{
|
757 |
if (fixed) |
|
758 |
{
|
|
759 |
char buf[22]; |
|
760 |
||
761 |
if (unsignd) |
|
151
by Brian Aker
Ulonglong to uint64_t |
762 |
ullstr((uint64_t) val, buf); |
1
by brian
clean slate |
763 |
else
|
764 |
llstr(val, buf); |
|
765 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
766 |
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, |
1
by brian
clean slate |
767 |
ER_TRUNCATED_WRONG_VALUE, |
768 |
ER(ER_TRUNCATED_WRONG_VALUE), name, buf); |
|
769 |
}
|
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
770 |
return false; |
1
by brian
clean slate |
771 |
}
|
772 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
773 |
static uint64_t fix_unsigned(Session *session, uint64_t num, |
1
by brian
clean slate |
774 |
const struct my_option *option_limits) |
775 |
{
|
|
143
by Brian Aker
Bool cleanup. |
776 |
bool fixed= false; |
151
by Brian Aker
Ulonglong to uint64_t |
777 |
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed); |
1
by brian
clean slate |
778 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
779 |
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num); |
1
by brian
clean slate |
780 |
return out; |
781 |
}
|
|
782 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
783 |
|
784 |
static size_t fix_size_t(Session *session, size_t num, |
|
785 |
const struct my_option *option_limits) |
|
786 |
{
|
|
787 |
bool fixed= false; |
|
788 |
size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed); |
|
789 |
||
790 |
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num); |
|
791 |
return out; |
|
792 |
}
|
|
793 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
794 |
static bool get_unsigned(Session *, set_var *var) |
1
by brian
clean slate |
795 |
{
|
796 |
if (var->value->unsigned_flag) |
|
151
by Brian Aker
Ulonglong to uint64_t |
797 |
var->save_result.uint64_t_value= (uint64_t) var->value->val_int(); |
1
by brian
clean slate |
798 |
else
|
799 |
{
|
|
152
by Brian Aker
longlong replacement |
800 |
int64_t v= var->value->val_int(); |
151
by Brian Aker
Ulonglong to uint64_t |
801 |
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v); |
1
by brian
clean slate |
802 |
}
|
803 |
return 0; |
|
804 |
}
|
|
805 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
806 |
static bool get_size_t(Session *, set_var *var) |
807 |
{
|
|
808 |
if (var->value->unsigned_flag) |
|
809 |
var->save_result.uint64_t_value= (size_t) var->value->val_int(); |
|
810 |
else
|
|
811 |
{
|
|
812 |
ssize_t v= var->value->val_int(); |
|
813 |
var->save_result.uint64_t_value= (size_t) ((v < 0) ? 0 : v); |
|
814 |
}
|
|
815 |
return 0; |
|
816 |
}
|
|
817 |
||
1
by brian
clean slate |
818 |
|
819 |
sys_var_long_ptr:: |
|
622
by Brian Aker
More ulong work. |
820 |
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg, |
1
by brian
clean slate |
821 |
sys_after_update_func after_update_arg) |
822 |
:sys_var_long_ptr_global(chain, name_arg, value_ptr_arg, |
|
823 |
&LOCK_global_system_variables, after_update_arg) |
|
824 |
{}
|
|
825 |
||
826 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
827 |
bool sys_var_long_ptr_global::check(Session *session, set_var *var) |
1
by brian
clean slate |
828 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
829 |
return get_unsigned(session, var); |
1
by brian
clean slate |
830 |
}
|
831 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
832 |
bool sys_var_long_ptr_global::update(Session *session, set_var *var) |
1
by brian
clean slate |
833 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
834 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
835 |
pthread_mutex_lock(guard); |
836 |
if (option_limits) |
|
622
by Brian Aker
More ulong work. |
837 |
*value= (uint64_t) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
838 |
else
|
839 |
{
|
|
481.1.5
by Monty Taylor
Removed sizeof(long) sizeof(long long) checks. |
840 |
if (tmp > UINT32_MAX) |
1
by brian
clean slate |
841 |
{
|
481.1.5
by Monty Taylor
Removed sizeof(long) sizeof(long long) checks. |
842 |
tmp= UINT32_MAX; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
843 |
throw_bounds_warning(session, true, true, name, |
152
by Brian Aker
longlong replacement |
844 |
(int64_t) var->save_result.uint64_t_value); |
1
by brian
clean slate |
845 |
}
|
622
by Brian Aker
More ulong work. |
846 |
*value= (uint64_t) tmp; |
1
by brian
clean slate |
847 |
}
|
848 |
||
849 |
pthread_mutex_unlock(guard); |
|
850 |
return 0; |
|
851 |
}
|
|
852 |
||
853 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
854 |
void sys_var_long_ptr_global::set_default(Session *, enum_var_type) |
1
by brian
clean slate |
855 |
{
|
143
by Brian Aker
Bool cleanup. |
856 |
bool not_used; |
1
by brian
clean slate |
857 |
pthread_mutex_lock(guard); |
622
by Brian Aker
More ulong work. |
858 |
*value= (uint64_t) getopt_ull_limit_value((uint64_t) option_limits->def_value, |
1
by brian
clean slate |
859 |
option_limits, ¬_used); |
860 |
pthread_mutex_unlock(guard); |
|
861 |
}
|
|
862 |
||
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
863 |
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var) |
864 |
{
|
|
865 |
uint32_t tmp= var->save_result.uint32_t_value; |
|
866 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
867 |
if (option_limits) |
|
868 |
*value= (uint32_t) fix_unsigned(session, tmp, option_limits); |
|
869 |
else
|
|
870 |
*value= (uint32_t) tmp; |
|
871 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
872 |
return 0; |
|
873 |
}
|
|
874 |
||
875 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
876 |
void sys_var_uint32_t_ptr::set_default(Session *, enum_var_type) |
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
877 |
{
|
878 |
bool not_used; |
|
879 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
880 |
*value= getopt_ull_limit_value((uint32_t) option_limits->def_value, |
|
881 |
option_limits, ¬_used); |
|
882 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
883 |
}
|
|
884 |
||
1
by brian
clean slate |
885 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
886 |
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var) |
1
by brian
clean slate |
887 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
888 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
889 |
pthread_mutex_lock(&LOCK_global_system_variables); |
890 |
if (option_limits) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
891 |
*value= (uint64_t) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
892 |
else
|
151
by Brian Aker
Ulonglong to uint64_t |
893 |
*value= (uint64_t) tmp; |
1
by brian
clean slate |
894 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
895 |
return 0; |
|
896 |
}
|
|
897 |
||
898 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
899 |
void sys_var_uint64_t_ptr::set_default(Session *, enum_var_type) |
1
by brian
clean slate |
900 |
{
|
143
by Brian Aker
Bool cleanup. |
901 |
bool not_used; |
1
by brian
clean slate |
902 |
pthread_mutex_lock(&LOCK_global_system_variables); |
151
by Brian Aker
Ulonglong to uint64_t |
903 |
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value, |
1
by brian
clean slate |
904 |
option_limits, ¬_used); |
905 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
906 |
}
|
|
907 |
||
908 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
909 |
bool sys_var_size_t_ptr::update(Session *session, set_var *var) |
910 |
{
|
|
911 |
size_t tmp= var->save_result.size_t_value; |
|
912 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
913 |
if (option_limits) |
|
914 |
*value= fix_size_t(session, tmp, option_limits); |
|
915 |
else
|
|
916 |
*value= tmp; |
|
917 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
918 |
return 0; |
|
919 |
}
|
|
920 |
||
921 |
||
922 |
void sys_var_size_t_ptr::set_default(Session *, enum_var_type) |
|
923 |
{
|
|
924 |
bool not_used; |
|
925 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
926 |
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value, |
|
927 |
option_limits, ¬_used); |
|
928 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
929 |
}
|
|
930 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
931 |
bool sys_var_bool_ptr::update(Session *, set_var *var) |
1
by brian
clean slate |
932 |
{
|
576
by Brian Aker
ulong conversion work |
933 |
*value= (bool) var->save_result.uint32_t_value; |
1
by brian
clean slate |
934 |
return 0; |
935 |
}
|
|
936 |
||
937 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
938 |
void sys_var_bool_ptr::set_default(Session *, enum_var_type) |
1
by brian
clean slate |
939 |
{
|
146
by Brian Aker
my_bool cleanup. |
940 |
*value= (bool) option_limits->def_value; |
941 |
}
|
|
942 |
||
1
by brian
clean slate |
943 |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
944 |
bool sys_var_enum::update(Session *, set_var *var) |
1
by brian
clean slate |
945 |
{
|
576
by Brian Aker
ulong conversion work |
946 |
*value= (uint) var->save_result.uint32_t_value; |
1
by brian
clean slate |
947 |
return 0; |
948 |
}
|
|
949 |
||
950 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
951 |
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, LEX_STRING *) |
1
by brian
clean slate |
952 |
{
|
481
by Brian Aker
Remove all of uchar. |
953 |
return (unsigned char*) enum_names->type_names[*value]; |
1
by brian
clean slate |
954 |
}
|
955 |
||
956 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
957 |
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type, |
958 |
LEX_STRING *) |
|
1
by brian
clean slate |
959 |
{
|
481
by Brian Aker
Remove all of uchar. |
960 |
return (unsigned char*) enum_names->type_names[global_system_variables.*offset]; |
1
by brian
clean slate |
961 |
}
|
962 |
||
615
by Brian Aker
Added 32bit system variable support |
963 |
/*
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
964 |
32 bit types for session variables
|
615
by Brian Aker
Added 32bit system variable support |
965 |
*/
|
966 |
bool sys_var_session_uint32_t::check(Session *session, set_var *var) |
|
967 |
{
|
|
968 |
return (get_unsigned(session, var) || |
|
969 |
(check_func && (*check_func)(session, var))); |
|
970 |
}
|
|
971 |
||
972 |
bool sys_var_session_uint32_t::update(Session *session, set_var *var) |
|
973 |
{
|
|
974 |
uint64_t tmp= var->save_result.uint64_t_value; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
975 |
|
615
by Brian Aker
Added 32bit system variable support |
976 |
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
977 |
if ((uint32_t) tmp > max_system_variables.*offset) |
|
978 |
{
|
|
979 |
throw_bounds_warning(session, true, true, name, (int64_t) tmp); |
|
980 |
tmp= max_system_variables.*offset; |
|
981 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
982 |
|
615
by Brian Aker
Added 32bit system variable support |
983 |
if (option_limits) |
984 |
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits); |
|
985 |
else if (tmp > UINT32_MAX) |
|
986 |
{
|
|
987 |
tmp= UINT32_MAX; |
|
988 |
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value); |
|
989 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
990 |
|
615
by Brian Aker
Added 32bit system variable support |
991 |
if (var->type == OPT_GLOBAL) |
992 |
global_system_variables.*offset= (uint32_t) tmp; |
|
993 |
else
|
|
994 |
session->variables.*offset= (uint32_t) tmp; |
|
995 |
||
996 |
return 0; |
|
997 |
}
|
|
998 |
||
999 |
||
1000 |
void sys_var_session_uint32_t::set_default(Session *session, enum_var_type type) |
|
1001 |
{
|
|
1002 |
if (type == OPT_GLOBAL) |
|
1003 |
{
|
|
1004 |
bool not_used; |
|
1005 |
/* We will not come here if option_limits is not set */
|
|
1006 |
global_system_variables.*offset= |
|
1007 |
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value, |
|
1008 |
option_limits, ¬_used); |
|
1009 |
}
|
|
1010 |
else
|
|
1011 |
session->variables.*offset= global_system_variables.*offset; |
|
1012 |
}
|
|
1013 |
||
1014 |
||
1015 |
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session, |
|
1016 |
enum_var_type type, |
|
1017 |
LEX_STRING *) |
|
1018 |
{
|
|
1019 |
if (type == OPT_GLOBAL) |
|
1020 |
return (unsigned char*) &(global_system_variables.*offset); |
|
1021 |
return (unsigned char*) &(session->variables.*offset); |
|
1022 |
}
|
|
1023 |
||
1
by brian
clean slate |
1024 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1025 |
bool sys_var_session_ha_rows::update(Session *session, set_var *var) |
1
by brian
clean slate |
1026 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
1027 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
1028 |
|
1029 |
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
|
1030 |
if ((ha_rows) tmp > max_system_variables.*offset) |
|
1031 |
tmp= max_system_variables.*offset; |
|
1032 |
||
1033 |
if (option_limits) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1034 |
tmp= (ha_rows) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
1035 |
if (var->type == OPT_GLOBAL) |
1036 |
{
|
|
1037 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1038 |
pthread_mutex_lock(&LOCK_global_system_variables); |
1
by brian
clean slate |
1039 |
global_system_variables.*offset= (ha_rows) tmp; |
1040 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1041 |
}
|
|
1042 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1043 |
session->variables.*offset= (ha_rows) tmp; |
1
by brian
clean slate |
1044 |
return 0; |
1045 |
}
|
|
1046 |
||
1047 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1048 |
void sys_var_session_ha_rows::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1049 |
{
|
1050 |
if (type == OPT_GLOBAL) |
|
1051 |
{
|
|
143
by Brian Aker
Bool cleanup. |
1052 |
bool not_used; |
1
by brian
clean slate |
1053 |
/* We will not come here if option_limits is not set */
|
1054 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1055 |
global_system_variables.*offset= |
|
1056 |
(ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value, |
|
1057 |
option_limits, ¬_used); |
|
1058 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1059 |
}
|
|
1060 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1061 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1062 |
}
|
1063 |
||
1064 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1065 |
unsigned char *sys_var_session_ha_rows::value_ptr(Session *session, |
1066 |
enum_var_type type, |
|
1067 |
LEX_STRING *) |
|
1
by brian
clean slate |
1068 |
{
|
1069 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
1070 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1071 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
1072 |
}
|
1073 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1074 |
bool sys_var_session_uint64_t::check(Session *session, set_var *var) |
1
by brian
clean slate |
1075 |
{
|
555
by Monty
Fixed 32-bit issues. |
1076 |
return (get_unsigned(session, var) || |
1077 |
(check_func && (*check_func)(session, var))); |
|
1
by brian
clean slate |
1078 |
}
|
1079 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1080 |
bool sys_var_session_uint64_t::update(Session *session, set_var *var) |
1
by brian
clean slate |
1081 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
1082 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
1083 |
|
1084 |
if (tmp > max_system_variables.*offset) |
|
1085 |
tmp= max_system_variables.*offset; |
|
1086 |
||
1087 |
if (option_limits) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1088 |
tmp= fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
1089 |
if (var->type == OPT_GLOBAL) |
1090 |
{
|
|
1091 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
1092 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
151
by Brian Aker
Ulonglong to uint64_t |
1093 |
global_system_variables.*offset= (uint64_t) tmp; |
1
by brian
clean slate |
1094 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1095 |
}
|
|
1096 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1097 |
session->variables.*offset= (uint64_t) tmp; |
1
by brian
clean slate |
1098 |
return 0; |
1099 |
}
|
|
1100 |
||
1101 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1102 |
void sys_var_session_uint64_t::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1103 |
{
|
1104 |
if (type == OPT_GLOBAL) |
|
1105 |
{
|
|
143
by Brian Aker
Bool cleanup. |
1106 |
bool not_used; |
1
by brian
clean slate |
1107 |
pthread_mutex_lock(&LOCK_global_system_variables); |
1108 |
global_system_variables.*offset= |
|
151
by Brian Aker
Ulonglong to uint64_t |
1109 |
getopt_ull_limit_value((uint64_t) option_limits->def_value, |
1
by brian
clean slate |
1110 |
option_limits, ¬_used); |
1111 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1112 |
}
|
|
1113 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1114 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1115 |
}
|
1116 |
||
1117 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1118 |
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session, |
1119 |
enum_var_type type, |
|
1120 |
LEX_STRING *) |
|
1
by brian
clean slate |
1121 |
{
|
1122 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
1123 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1124 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
1125 |
}
|
1126 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
1127 |
bool sys_var_session_size_t::check(Session *session, set_var *var) |
1128 |
{
|
|
1129 |
return (get_size_t(session, var) || |
|
1130 |
(check_func && (*check_func)(session, var))); |
|
1131 |
}
|
|
1132 |
||
1133 |
bool sys_var_session_size_t::update(Session *session, set_var *var) |
|
1134 |
{
|
|
1135 |
size_t tmp= var->save_result.size_t_value; |
|
1136 |
||
1137 |
if (tmp > max_system_variables.*offset) |
|
1138 |
tmp= max_system_variables.*offset; |
|
1139 |
||
1140 |
if (option_limits) |
|
1141 |
tmp= fix_size_t(session, tmp, option_limits); |
|
1142 |
if (var->type == OPT_GLOBAL) |
|
1143 |
{
|
|
1144 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
1145 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1146 |
global_system_variables.*offset= tmp; |
|
1147 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1148 |
}
|
|
1149 |
else
|
|
1150 |
session->variables.*offset= tmp; |
|
1151 |
return 0; |
|
1152 |
}
|
|
1153 |
||
1154 |
||
1155 |
void sys_var_session_size_t::set_default(Session *session, enum_var_type type) |
|
1156 |
{
|
|
1157 |
if (type == OPT_GLOBAL) |
|
1158 |
{
|
|
1159 |
bool not_used; |
|
1160 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1161 |
global_system_variables.*offset= |
|
1162 |
getopt_ull_limit_value((size_t) option_limits->def_value, |
|
1163 |
option_limits, ¬_used); |
|
1164 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1165 |
}
|
|
1166 |
else
|
|
1167 |
session->variables.*offset= global_system_variables.*offset; |
|
1168 |
}
|
|
1169 |
||
1170 |
||
1171 |
unsigned char *sys_var_session_size_t::value_ptr(Session *session, |
|
1172 |
enum_var_type type, |
|
1173 |
LEX_STRING *) |
|
1174 |
{
|
|
1175 |
if (type == OPT_GLOBAL) |
|
1176 |
return (unsigned char*) &(global_system_variables.*offset); |
|
1177 |
return (unsigned char*) &(session->variables.*offset); |
|
1178 |
}
|
|
1179 |
||
1
by brian
clean slate |
1180 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1181 |
bool sys_var_session_bool::update(Session *session, set_var *var) |
1
by brian
clean slate |
1182 |
{
|
1183 |
if (var->type == OPT_GLOBAL) |
|
576
by Brian Aker
ulong conversion work |
1184 |
global_system_variables.*offset= (bool) var->save_result.uint32_t_value; |
1
by brian
clean slate |
1185 |
else
|
576
by Brian Aker
ulong conversion work |
1186 |
session->variables.*offset= (bool) var->save_result.uint32_t_value; |
1
by brian
clean slate |
1187 |
return 0; |
1188 |
}
|
|
1189 |
||
1190 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1191 |
void sys_var_session_bool::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1192 |
{
|
1193 |
if (type == OPT_GLOBAL) |
|
200
by Brian Aker
my_bool from handler and set_var |
1194 |
global_system_variables.*offset= (bool) option_limits->def_value; |
1
by brian
clean slate |
1195 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1196 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1197 |
}
|
1198 |
||
1199 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1200 |
unsigned char *sys_var_session_bool::value_ptr(Session *session, |
1201 |
enum_var_type type, |
|
1202 |
LEX_STRING *) |
|
1
by brian
clean slate |
1203 |
{
|
1204 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
1205 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1206 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
1207 |
}
|
1208 |
||
1209 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1210 |
bool sys_var::check_enum(Session *, |
77.1.45
by Monty Taylor
Warning fixes. |
1211 |
set_var *var, const TYPELIB *enum_names) |
1
by brian
clean slate |
1212 |
{
|
1213 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
1214 |
const char *value; |
|
1215 |
String str(buff, sizeof(buff), system_charset_info), *res; |
|
1216 |
||
1217 |
if (var->value->result_type() == STRING_RESULT) |
|
1218 |
{
|
|
576
by Brian Aker
ulong conversion work |
1219 |
if (!(res=var->value->val_str(&str))) |
1
by brian
clean slate |
1220 |
{
|
1221 |
value= res ? res->c_ptr() : "NULL"; |
|
1222 |
goto err; |
|
1223 |
}
|
|
1224 |
}
|
|
1225 |
else
|
|
1226 |
{
|
|
151
by Brian Aker
Ulonglong to uint64_t |
1227 |
uint64_t tmp=var->value->val_int(); |
1
by brian
clean slate |
1228 |
if (tmp >= enum_names->count) |
1229 |
{
|
|
1230 |
llstr(tmp,buff); |
|
1231 |
value=buff; // Wrong value is here |
|
1232 |
goto err; |
|
1233 |
}
|
|
576
by Brian Aker
ulong conversion work |
1234 |
var->save_result.uint32_t_value= (uint32_t) tmp; // Save for update |
1
by brian
clean slate |
1235 |
}
|
1236 |
return 0; |
|
1237 |
||
1238 |
err: |
|
1239 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, value); |
|
1240 |
return 1; |
|
1241 |
}
|
|
1242 |
||
1243 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1244 |
bool sys_var::check_set(Session *, set_var *var, TYPELIB *enum_names) |
1
by brian
clean slate |
1245 |
{
|
1246 |
bool not_used; |
|
1247 |
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0; |
|
482
by Brian Aker
Remove uint. |
1248 |
uint32_t error_len= 0; |
1
by brian
clean slate |
1249 |
String str(buff, sizeof(buff), system_charset_info), *res; |
1250 |
||
1251 |
if (var->value->result_type() == STRING_RESULT) |
|
1252 |
{
|
|
1253 |
if (!(res= var->value->val_str(&str))) |
|
1254 |
{
|
|
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
1255 |
strcpy(buff, "NULL"); |
1
by brian
clean slate |
1256 |
goto err; |
1257 |
}
|
|
1258 |
||
1259 |
if (!m_allow_empty_value && |
|
1260 |
res->length() == 0) |
|
1261 |
{
|
|
1262 |
buff[0]= 0; |
|
1263 |
goto err; |
|
1264 |
}
|
|
1265 |
||
576
by Brian Aker
ulong conversion work |
1266 |
var->save_result.uint32_t_value= ((uint32_t) |
1
by brian
clean slate |
1267 |
find_set(enum_names, res->c_ptr(), |
1268 |
res->length(), |
|
1269 |
NULL, |
|
1270 |
&error, &error_len, |
|
1271 |
¬_used)); |
|
1272 |
if (error_len) |
|
1273 |
{
|
|
629.5.3
by Toru Maesaka
Third pass of replacing MySQL's strmake() with libc calls |
1274 |
size_t len = cmin(sizeof(buff) - 1, error_len); |
1275 |
strncpy(buff, error, len); |
|
1276 |
buff[len]= '\0'; |
|
1
by brian
clean slate |
1277 |
goto err; |
1278 |
}
|
|
1279 |
}
|
|
1280 |
else
|
|
1281 |
{
|
|
151
by Brian Aker
Ulonglong to uint64_t |
1282 |
uint64_t tmp= var->value->val_int(); |
1
by brian
clean slate |
1283 |
|
1284 |
if (!m_allow_empty_value && |
|
1285 |
tmp == 0) |
|
1286 |
{
|
|
1287 |
buff[0]= '0'; |
|
1288 |
buff[1]= 0; |
|
1289 |
goto err; |
|
1290 |
}
|
|
1291 |
||
1292 |
/*
|
|
1293 |
For when the enum is made to contain 64 elements, as 1ULL<<64 is
|
|
1294 |
undefined, we guard with a "count<64" test.
|
|
1295 |
*/
|
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1296 |
if (unlikely((tmp >= ((1UL) << enum_names->count)) && |
1
by brian
clean slate |
1297 |
(enum_names->count < 64))) |
1298 |
{
|
|
1299 |
llstr(tmp, buff); |
|
1300 |
goto err; |
|
1301 |
}
|
|
576
by Brian Aker
ulong conversion work |
1302 |
var->save_result.uint32_t_value= (uint32_t) tmp; // Save for update |
1
by brian
clean slate |
1303 |
}
|
1304 |
return 0; |
|
1305 |
||
1306 |
err: |
|
1307 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buff); |
|
1308 |
return 1; |
|
1309 |
}
|
|
1310 |
||
1311 |
||
1312 |
/**
|
|
1313 |
Return an Item for a variable.
|
|
1314 |
||
1315 |
Used with @@[global.]variable_name.
|
|
1316 |
||
1317 |
If type is not given, return local value if exists, else global.
|
|
1318 |
*/
|
|
1319 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1320 |
Item *sys_var::item(Session *session, enum_var_type var_type, LEX_STRING *base) |
1
by brian
clean slate |
1321 |
{
|
1322 |
if (check_type(var_type)) |
|
1323 |
{
|
|
1324 |
if (var_type != OPT_DEFAULT) |
|
1325 |
{
|
|
1326 |
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), |
|
1327 |
name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); |
|
1328 |
return 0; |
|
1329 |
}
|
|
1330 |
/* As there was no local variable, return the global value */
|
|
1331 |
var_type= OPT_GLOBAL; |
|
1332 |
}
|
|
1333 |
switch (show_type()) { |
|
625
by Brian Aker
ulong/64 bit straighten out. |
1334 |
case SHOW_LONG: |
1
by brian
clean slate |
1335 |
case SHOW_INT: |
1336 |
{
|
|
482
by Brian Aker
Remove uint. |
1337 |
uint32_t value; |
1
by brian
clean slate |
1338 |
pthread_mutex_lock(&LOCK_global_system_variables); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1339 |
value= *(uint*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1340 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
151
by Brian Aker
Ulonglong to uint64_t |
1341 |
return new Item_uint((uint64_t) value); |
1
by brian
clean slate |
1342 |
}
|
1343 |
case SHOW_LONGLONG: |
|
1344 |
{
|
|
152
by Brian Aker
longlong replacement |
1345 |
int64_t value; |
1
by brian
clean slate |
1346 |
pthread_mutex_lock(&LOCK_global_system_variables); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1347 |
value= *(int64_t*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1348 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1349 |
return new Item_int(value); |
|
1350 |
}
|
|
1351 |
case SHOW_DOUBLE: |
|
1352 |
{
|
|
1353 |
double value; |
|
1354 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1355 |
value= *(double*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1356 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1357 |
/* 6, as this is for now only used with microseconds */
|
|
1358 |
return new Item_float(value, 6); |
|
1359 |
}
|
|
1360 |
case SHOW_HA_ROWS: |
|
1361 |
{
|
|
1362 |
ha_rows value; |
|
1363 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1364 |
value= *(ha_rows*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1365 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
151
by Brian Aker
Ulonglong to uint64_t |
1366 |
return new Item_int((uint64_t) value); |
1
by brian
clean slate |
1367 |
}
|
673.3.17
by Stewart Smith
mostly fix repair test. fix syntax for Drizzle (all tests are MyISAM reliant). |
1368 |
case SHOW_SIZE: |
1369 |
{
|
|
1370 |
size_t value; |
|
1371 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1372 |
value= *(size_t*) value_ptr(session, var_type, base); |
|
1373 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1374 |
return new Item_int((uint64_t) value); |
|
1375 |
}
|
|
1
by brian
clean slate |
1376 |
case SHOW_MY_BOOL: |
1377 |
{
|
|
205
by Brian Aker
uint32 -> uin32_t |
1378 |
int32_t value; |
1
by brian
clean slate |
1379 |
pthread_mutex_lock(&LOCK_global_system_variables); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1380 |
value= *(bool*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1381 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1382 |
return new Item_int(value,1); |
|
1383 |
}
|
|
1384 |
case SHOW_CHAR_PTR: |
|
1385 |
{
|
|
1386 |
Item *tmp; |
|
1387 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1388 |
char *str= *(char**) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1389 |
if (str) |
1390 |
{
|
|
482
by Brian Aker
Remove uint. |
1391 |
uint32_t length= strlen(str); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1392 |
tmp= new Item_string(session->strmake(str, length), length, |
1
by brian
clean slate |
1393 |
system_charset_info, DERIVATION_SYSCONST); |
1394 |
}
|
|
1395 |
else
|
|
1396 |
{
|
|
1397 |
tmp= new Item_null(); |
|
1398 |
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); |
|
1399 |
}
|
|
1400 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1401 |
return tmp; |
|
1402 |
}
|
|
1403 |
case SHOW_CHAR: |
|
1404 |
{
|
|
1405 |
Item *tmp; |
|
1406 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1407 |
char *str= (char*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1408 |
if (str) |
1409 |
tmp= new Item_string(str, strlen(str), |
|
1410 |
system_charset_info, DERIVATION_SYSCONST); |
|
1411 |
else
|
|
1412 |
{
|
|
1413 |
tmp= new Item_null(); |
|
1414 |
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); |
|
1415 |
}
|
|
1416 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1417 |
return tmp; |
|
1418 |
}
|
|
1419 |
default: |
|
1420 |
my_error(ER_VAR_CANT_BE_READ, MYF(0), name); |
|
1421 |
}
|
|
1422 |
return 0; |
|
1423 |
}
|
|
1424 |
||
1425 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1426 |
bool sys_var_session_enum::update(Session *session, set_var *var) |
1
by brian
clean slate |
1427 |
{
|
1428 |
if (var->type == OPT_GLOBAL) |
|
576
by Brian Aker
ulong conversion work |
1429 |
global_system_variables.*offset= var->save_result.uint32_t_value; |
1
by brian
clean slate |
1430 |
else
|
576
by Brian Aker
ulong conversion work |
1431 |
session->variables.*offset= var->save_result.uint32_t_value; |
1
by brian
clean slate |
1432 |
return 0; |
1433 |
}
|
|
1434 |
||
1435 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1436 |
void sys_var_session_enum::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1437 |
{
|
1438 |
if (type == OPT_GLOBAL) |
|
621
by Brian Aker
ulong fixes |
1439 |
global_system_variables.*offset= (uint32_t) option_limits->def_value; |
1
by brian
clean slate |
1440 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1441 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1442 |
}
|
1443 |
||
1444 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1445 |
unsigned char *sys_var_session_enum::value_ptr(Session *session, |
1446 |
enum_var_type type, |
|
1447 |
LEX_STRING *) |
|
1
by brian
clean slate |
1448 |
{
|
621
by Brian Aker
ulong fixes |
1449 |
uint32_t tmp= ((type == OPT_GLOBAL) ? |
1
by brian
clean slate |
1450 |
global_system_variables.*offset : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1451 |
session->variables.*offset); |
481
by Brian Aker
Remove all of uchar. |
1452 |
return (unsigned char*) enum_names->type_names[tmp]; |
1
by brian
clean slate |
1453 |
}
|
1454 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1455 |
bool sys_var_session_bit::check(Session *session, set_var *var) |
1
by brian
clean slate |
1456 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1457 |
return (check_enum(session, var, &bool_typelib) || |
1458 |
(check_func && (*check_func)(session, var))); |
|
1
by brian
clean slate |
1459 |
}
|
1460 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1461 |
bool sys_var_session_bit::update(Session *session, set_var *var) |
1
by brian
clean slate |
1462 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1463 |
int res= (*update_func)(session, var); |
1
by brian
clean slate |
1464 |
return res; |
1465 |
}
|
|
1466 |
||
1467 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1468 |
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type, |
1469 |
LEX_STRING *) |
|
1
by brian
clean slate |
1470 |
{
|
1471 |
/*
|
|
1472 |
If reverse is 0 (default) return 1 if bit is set.
|
|
1473 |
If reverse is 1, return 0 if bit is set
|
|
1474 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1475 |
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ? |
1
by brian
clean slate |
1476 |
!reverse : reverse); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1477 |
return (unsigned char*) &session->sys_var_tmp.bool_value; |
1
by brian
clean slate |
1478 |
}
|
1479 |
||
1480 |
||
1481 |
/** Update a date_time format variable based on given value. */
|
|
1482 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1483 |
void sys_var_session_date_time_format::update2(Session *session, enum_var_type type, |
1
by brian
clean slate |
1484 |
DATE_TIME_FORMAT *new_value) |
1485 |
{
|
|
1486 |
DATE_TIME_FORMAT *old; |
|
1487 |
||
1488 |
if (type == OPT_GLOBAL) |
|
1489 |
{
|
|
1490 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1491 |
old= (global_system_variables.*offset); |
|
1492 |
(global_system_variables.*offset)= new_value; |
|
1493 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1494 |
}
|
|
1495 |
else
|
|
1496 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1497 |
old= (session->variables.*offset); |
1498 |
(session->variables.*offset)= new_value; |
|
1
by brian
clean slate |
1499 |
}
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1500 |
free((char*) old); |
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1501 |
return; |
1
by brian
clean slate |
1502 |
}
|
1503 |
||
1504 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1505 |
bool sys_var_session_date_time_format::update(Session *session, set_var *var) |
1
by brian
clean slate |
1506 |
{
|
1507 |
DATE_TIME_FORMAT *new_value; |
|
1508 |
/* We must make a copy of the last value to get it into normal memory */
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1509 |
new_value= date_time_format_copy((Session*) 0, |
1
by brian
clean slate |
1510 |
var->save_result.date_time_format); |
1511 |
if (!new_value) |
|
1512 |
return 1; // Out of memory |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1513 |
update2(session, var->type, new_value); // Can't fail |
1
by brian
clean slate |
1514 |
return 0; |
1515 |
}
|
|
1516 |
||
1517 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1518 |
bool sys_var_session_date_time_format::check(Session *session, set_var *var) |
1
by brian
clean slate |
1519 |
{
|
1520 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
1521 |
String str(buff,sizeof(buff), system_charset_info), *res; |
|
1522 |
DATE_TIME_FORMAT *format; |
|
1523 |
||
1524 |
if (!(res=var->value->val_str(&str))) |
|
1525 |
res= &my_empty_string; |
|
1526 |
||
1527 |
if (!(format= date_time_format_make(date_time_type, |
|
1528 |
res->ptr(), res->length()))) |
|
1529 |
{
|
|
1530 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr()); |
|
1531 |
return 1; |
|
1532 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1533 |
|
1
by brian
clean slate |
1534 |
/*
|
1535 |
We must copy result to thread space to not get a memory leak if
|
|
1536 |
update is aborted
|
|
1537 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1538 |
var->save_result.date_time_format= date_time_format_copy(session, format); |
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1539 |
free((char*) format); |
1
by brian
clean slate |
1540 |
return var->save_result.date_time_format == 0; |
1541 |
}
|
|
1542 |
||
1543 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1544 |
void sys_var_session_date_time_format::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1545 |
{
|
1546 |
DATE_TIME_FORMAT *res= 0; |
|
1547 |
||
1548 |
if (type == OPT_GLOBAL) |
|
1549 |
{
|
|
1550 |
const char *format; |
|
1551 |
if ((format= opt_date_time_formats[date_time_type])) |
|
1552 |
res= date_time_format_make(date_time_type, format, strlen(format)); |
|
1553 |
}
|
|
1554 |
else
|
|
1555 |
{
|
|
1556 |
/* Make copy with malloc */
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1557 |
res= date_time_format_copy((Session *) 0, global_system_variables.*offset); |
1
by brian
clean slate |
1558 |
}
|
1559 |
||
1560 |
if (res) // Should always be true |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1561 |
update2(session, type, res); |
1
by brian
clean slate |
1562 |
}
|
1563 |
||
1564 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1565 |
unsigned char *sys_var_session_date_time_format::value_ptr(Session *session, |
1566 |
enum_var_type type, |
|
1567 |
LEX_STRING *) |
|
1
by brian
clean slate |
1568 |
{
|
1569 |
if (type == OPT_GLOBAL) |
|
1570 |
{
|
|
1571 |
char *res; |
|
1572 |
/*
|
|
1573 |
We do a copy here just to be sure things will work even if someone
|
|
1574 |
is modifying the original string while the copy is accessed
|
|
1575 |
(Can't happen now in SQL SHOW, but this is a good safety for the future)
|
|
1576 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1577 |
res= session->strmake((global_system_variables.*offset)->format.str, |
1
by brian
clean slate |
1578 |
(global_system_variables.*offset)->format.length); |
481
by Brian Aker
Remove all of uchar. |
1579 |
return (unsigned char*) res; |
1
by brian
clean slate |
1580 |
}
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1581 |
return (unsigned char*) (session->variables.*offset)->format.str; |
1
by brian
clean slate |
1582 |
}
|
1583 |
||
1584 |
||
1585 |
typedef struct old_names_map_st |
|
1586 |
{
|
|
1587 |
const char *old_name; |
|
1588 |
const char *new_name; |
|
1589 |
} my_old_conv; |
|
1590 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1591 |
bool sys_var_collation::check(Session *, set_var *var) |
1
by brian
clean slate |
1592 |
{
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1593 |
const CHARSET_INFO *tmp; |
1
by brian
clean slate |
1594 |
|
1595 |
if (var->value->result_type() == STRING_RESULT) |
|
1596 |
{
|
|
1597 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
1598 |
String str(buff,sizeof(buff), system_charset_info), *res; |
|
1599 |
if (!(res=var->value->val_str(&str))) |
|
1600 |
{
|
|
1601 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); |
|
1602 |
return 1; |
|
1603 |
}
|
|
1604 |
if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0)))) |
|
1605 |
{
|
|
1606 |
my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr()); |
|
1607 |
return 1; |
|
1608 |
}
|
|
1609 |
}
|
|
1610 |
else // INT_RESULT |
|
1611 |
{
|
|
1612 |
if (!(tmp=get_charset((int) var->value->val_int(),MYF(0)))) |
|
1613 |
{
|
|
1614 |
char buf[20]; |
|
1615 |
int10_to_str((int) var->value->val_int(), buf, -10); |
|
1616 |
my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); |
|
1617 |
return 1; |
|
1618 |
}
|
|
1619 |
}
|
|
1620 |
var->save_result.charset= tmp; // Save for update |
|
1621 |
return 0; |
|
1622 |
}
|
|
1623 |
||
1624 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1625 |
bool sys_var_collation_sv::update(Session *session, set_var *var) |
1
by brian
clean slate |
1626 |
{
|
1627 |
if (var->type == OPT_GLOBAL) |
|
1628 |
global_system_variables.*offset= var->save_result.charset; |
|
1629 |
else
|
|
1630 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1631 |
session->variables.*offset= var->save_result.charset; |
1632 |
session->update_charset(); |
|
1
by brian
clean slate |
1633 |
}
|
1634 |
return 0; |
|
1635 |
}
|
|
1636 |
||
1637 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1638 |
void sys_var_collation_sv::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1639 |
{
|
1640 |
if (type == OPT_GLOBAL) |
|
1641 |
global_system_variables.*offset= *global_default; |
|
1642 |
else
|
|
1643 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1644 |
session->variables.*offset= global_system_variables.*offset; |
1645 |
session->update_charset(); |
|
1
by brian
clean slate |
1646 |
}
|
1647 |
}
|
|
1648 |
||
1649 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1650 |
unsigned char *sys_var_collation_sv::value_ptr(Session *session, |
1651 |
enum_var_type type, |
|
1652 |
LEX_STRING *) |
|
1
by brian
clean slate |
1653 |
{
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1654 |
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? |
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1655 |
global_system_variables.*offset : |
1656 |
session->variables.*offset); |
|
481
by Brian Aker
Remove all of uchar. |
1657 |
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL"; |
1
by brian
clean slate |
1658 |
}
|
1659 |
||
1660 |
||
1661 |
LEX_STRING default_key_cache_base= {(char *) "default", 7 }; |
|
1662 |
||
1663 |
static KEY_CACHE zero_key_cache; |
|
1664 |
||
1665 |
KEY_CACHE *get_key_cache(LEX_STRING *cache_name) |
|
1666 |
{
|
|
1667 |
safe_mutex_assert_owner(&LOCK_global_system_variables); |
|
1668 |
if (!cache_name || ! cache_name->length) |
|
1669 |
cache_name= &default_key_cache_base; |
|
1670 |
return ((KEY_CACHE*) find_named(&key_caches, |
|
1671 |
cache_name->str, cache_name->length, 0)); |
|
1672 |
}
|
|
1673 |
||
1674 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1675 |
unsigned char *sys_var_key_cache_param::value_ptr(Session *, enum_var_type, |
1676 |
LEX_STRING *base) |
|
1
by brian
clean slate |
1677 |
{
|
1678 |
KEY_CACHE *key_cache= get_key_cache(base); |
|
1679 |
if (!key_cache) |
|
1680 |
key_cache= &zero_key_cache; |
|
481
by Brian Aker
Remove all of uchar. |
1681 |
return (unsigned char*) key_cache + offset ; |
1
by brian
clean slate |
1682 |
}
|
1683 |
||
1684 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1685 |
bool sys_var_key_buffer_size::update(Session *session, set_var *var) |
1
by brian
clean slate |
1686 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
1687 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
1688 |
LEX_STRING *base_name= &var->base; |
1689 |
KEY_CACHE *key_cache; |
|
1690 |
bool error= 0; |
|
1691 |
||
1692 |
/* If no basename, assume it's for the key cache named 'default' */
|
|
1693 |
if (!base_name->length) |
|
1694 |
base_name= &default_key_cache_base; |
|
1695 |
||
1696 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1697 |
key_cache= get_key_cache(base_name); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1698 |
|
1
by brian
clean slate |
1699 |
if (!key_cache) |
1700 |
{
|
|
1701 |
/* Key cache didn't exists */
|
|
1702 |
if (!tmp) // Tried to delete cache |
|
1703 |
goto end; // Ok, nothing to do |
|
1704 |
if (!(key_cache= create_key_cache(base_name->str, base_name->length))) |
|
1705 |
{
|
|
1706 |
error= 1; |
|
1707 |
goto end; |
|
1708 |
}
|
|
1709 |
}
|
|
1710 |
||
1711 |
/*
|
|
1712 |
Abort if some other thread is changing the key cache
|
|
1713 |
TODO: This should be changed so that we wait until the previous
|
|
1714 |
assignment is done and then do the new assign
|
|
1715 |
*/
|
|
1716 |
if (key_cache->in_init) |
|
1717 |
goto end; |
|
1718 |
||
1719 |
if (!tmp) // Zero size means delete |
|
1720 |
{
|
|
1721 |
if (key_cache == dflt_key_cache) |
|
1722 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1723 |
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, |
1
by brian
clean slate |
1724 |
ER_WARN_CANT_DROP_DEFAULT_KEYCACHE, |
1725 |
ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE)); |
|
1726 |
goto end; // Ignore default key cache |
|
1727 |
}
|
|
1728 |
||
1729 |
if (key_cache->key_cache_inited) // If initied |
|
1730 |
{
|
|
1731 |
/*
|
|
1732 |
Move tables using this key cache to the default key cache
|
|
1733 |
and clear the old key cache.
|
|
1734 |
*/
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1735 |
NAMED_LIST *list; |
1
by brian
clean slate |
1736 |
key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str, |
1737 |
base_name->length, &list); |
|
1738 |
key_cache->in_init= 1; |
|
1739 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1740 |
error= reassign_keycache_tables(session, key_cache, dflt_key_cache); |
1
by brian
clean slate |
1741 |
pthread_mutex_lock(&LOCK_global_system_variables); |
1742 |
key_cache->in_init= 0; |
|
1743 |
}
|
|
1744 |
/*
|
|
1745 |
We don't delete the key cache as some running threads my still be
|
|
1746 |
in the key cache code with a pointer to the deleted (empty) key cache
|
|
1747 |
*/
|
|
1748 |
goto end; |
|
1749 |
}
|
|
1750 |
||
1751 |
key_cache->param_buff_size= |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1752 |
(uint64_t) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
1753 |
|
1754 |
/* If key cache didn't existed initialize it, else resize it */
|
|
1755 |
key_cache->in_init= 1; |
|
1756 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1757 |
||
1758 |
if (!key_cache->key_cache_inited) |
|
1759 |
error= (bool) (ha_init_key_cache("", key_cache)); |
|
1760 |
else
|
|
1761 |
error= (bool)(ha_resize_key_cache(key_cache)); |
|
1762 |
||
1763 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1764 |
key_cache->in_init= 0; |
1
by brian
clean slate |
1765 |
|
1766 |
end: |
|
1767 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1768 |
return error; |
|
1769 |
}
|
|
1770 |
||
1771 |
||
1772 |
/**
|
|
1773 |
@todo
|
|
1774 |
Abort if some other thread is changing the key cache.
|
|
1775 |
This should be changed so that we wait until the previous
|
|
1776 |
assignment is done and then do the new assign
|
|
1777 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1778 |
bool sys_var_key_cache_long::update(Session *session, set_var *var) |
1
by brian
clean slate |
1779 |
{
|
622
by Brian Aker
More ulong work. |
1780 |
uint64_t tmp= (uint64_t) var->value->val_int(); |
1
by brian
clean slate |
1781 |
LEX_STRING *base_name= &var->base; |
1782 |
bool error= 0; |
|
1783 |
||
1784 |
if (!base_name->length) |
|
1785 |
base_name= &default_key_cache_base; |
|
1786 |
||
1787 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1788 |
KEY_CACHE *key_cache= get_key_cache(base_name); |
|
1789 |
||
1790 |
if (!key_cache && !(key_cache= create_key_cache(base_name->str, |
|
1791 |
base_name->length))) |
|
1792 |
{
|
|
1793 |
error= 1; |
|
1794 |
goto end; |
|
1795 |
}
|
|
1796 |
||
1797 |
/*
|
|
1798 |
Abort if some other thread is changing the key cache
|
|
1799 |
TODO: This should be changed so that we wait until the previous
|
|
1800 |
assignment is done and then do the new assign
|
|
1801 |
*/
|
|
1802 |
if (key_cache->in_init) |
|
1803 |
goto end; |
|
1804 |
||
622
by Brian Aker
More ulong work. |
1805 |
*((uint64_t*) (((char*) key_cache) + offset))= |
1806 |
(uint64_t) fix_unsigned(session, tmp, option_limits); |
|
1
by brian
clean slate |
1807 |
|
1808 |
/*
|
|
1809 |
Don't create a new key cache if it didn't exist
|
|
1810 |
(key_caches are created only when the user sets block_size)
|
|
1811 |
*/
|
|
1812 |
key_cache->in_init= 1; |
|
1813 |
||
1814 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1815 |
||
1816 |
error= (bool) (ha_resize_key_cache(key_cache)); |
|
1817 |
||
1818 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1819 |
key_cache->in_init= 0; |
1
by brian
clean slate |
1820 |
|
1821 |
end: |
|
1822 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1823 |
return error; |
|
1824 |
}
|
|
1825 |
||
1826 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1827 |
bool sys_var_log_state::update(Session *, set_var *var) |
1
by brian
clean slate |
1828 |
{
|
1829 |
bool res; |
|
1830 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
576
by Brian Aker
ulong conversion work |
1831 |
if (!var->save_result.uint32_t_value) |
1
by brian
clean slate |
1832 |
res= false; |
1833 |
else
|
|
438.1.2
by Brian Aker
More refactoring out of the old logging system. |
1834 |
res= true; |
1
by brian
clean slate |
1835 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1836 |
return res; |
|
1837 |
}
|
|
1838 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1839 |
void sys_var_log_state::set_default(Session *, enum_var_type) |
1
by brian
clean slate |
1840 |
{
|
1841 |
}
|
|
1842 |
||
1843 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1844 |
bool update_sys_var_str_path(Session *, sys_var_str *var_str, |
77.1.45
by Monty Taylor
Warning fixes. |
1845 |
set_var *var, const char *log_ext, |
482
by Brian Aker
Remove uint. |
1846 |
bool log_state, uint32_t log_type) |
1
by brian
clean slate |
1847 |
{
|
1848 |
char buff[FN_REFLEN]; |
|
1849 |
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0); |
|
1850 |
bool result= 0; |
|
482
by Brian Aker
Remove uint. |
1851 |
uint32_t str_length= (var ? var->value->str_value.length() : 0); |
1
by brian
clean slate |
1852 |
|
1853 |
switch (log_type) { |
|
1854 |
default: |
|
1855 |
assert(0); // Impossible |
|
1856 |
}
|
|
1857 |
||
1858 |
if (!old_value) |
|
1859 |
{
|
|
1860 |
old_value= make_default_log_name(buff, log_ext); |
|
1861 |
str_length= strlen(old_value); |
|
1862 |
}
|
|
656.1.34
by Monty Taylor
Got closer... |
1863 |
res= (char *)malloc(str_length + 1); |
656.1.32
by Monty Taylor
Removed strndup. (doesn't exist on solaris) |
1864 |
if (res == NULL) |
1
by brian
clean slate |
1865 |
{
|
1866 |
result= 1; |
|
1867 |
goto err; |
|
1868 |
}
|
|
656.1.34
by Monty Taylor
Got closer... |
1869 |
memcpy(res, old_value, str_length); |
1870 |
res[str_length]= 0; |
|
1
by brian
clean slate |
1871 |
|
1872 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1873 |
||
1874 |
old_value= var_str->value; |
|
1875 |
var_str->value= res; |
|
1876 |
var_str->value_length= str_length; |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1877 |
free(old_value); |
438.1.1
by Brian Aker
First pass of removing historical logging. |
1878 |
if (log_state) |
1
by brian
clean slate |
1879 |
{
|
1880 |
switch (log_type) { |
|
1881 |
default: |
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1882 |
assert(0); |
1
by brian
clean slate |
1883 |
}
|
1884 |
}
|
|
1885 |
||
1886 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1887 |
||
1888 |
err: |
|
1889 |
return result; |
|
1890 |
}
|
|
1891 |
||
1892 |
/****************************************************************************/
|
|
1893 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1894 |
bool sys_var_timestamp::update(Session *session, set_var *var) |
1
by brian
clean slate |
1895 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1896 |
session->set_time((time_t) var->save_result.uint64_t_value); |
1
by brian
clean slate |
1897 |
return 0; |
1898 |
}
|
|
1899 |
||
1900 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1901 |
void sys_var_timestamp::set_default(Session *session, enum_var_type) |
1
by brian
clean slate |
1902 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1903 |
session->user_time=0; |
1
by brian
clean slate |
1904 |
}
|
1905 |
||
1906 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1907 |
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type, |
1908 |
LEX_STRING *) |
|
1
by brian
clean slate |
1909 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1910 |
session->sys_var_tmp.long_value= (long) session->start_time; |
1911 |
return (unsigned char*) &session->sys_var_tmp.long_value; |
|
1
by brian
clean slate |
1912 |
}
|
1913 |
||
1914 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1915 |
bool sys_var_last_insert_id::update(Session *session, set_var *var) |
1
by brian
clean slate |
1916 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1917 |
session->first_successful_insert_id_in_prev_stmt= |
151
by Brian Aker
Ulonglong to uint64_t |
1918 |
var->save_result.uint64_t_value; |
1
by brian
clean slate |
1919 |
return 0; |
1920 |
}
|
|
1921 |
||
1922 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1923 |
unsigned char *sys_var_last_insert_id::value_ptr(Session *session, |
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1924 |
enum_var_type, |
1925 |
LEX_STRING *) |
|
1
by brian
clean slate |
1926 |
{
|
1927 |
/*
|
|
77.1.45
by Monty Taylor
Warning fixes. |
1928 |
this tmp var makes it robust againt change of type of
|
1
by brian
clean slate |
1929 |
read_first_successful_insert_id_in_prev_stmt().
|
1930 |
*/
|
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1931 |
session->sys_var_tmp.uint64_t_value= |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1932 |
session->read_first_successful_insert_id_in_prev_stmt(); |
1933 |
return (unsigned char*) &session->sys_var_tmp.uint64_t_value; |
|
1
by brian
clean slate |
1934 |
}
|
1935 |
||
1936 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1937 |
bool sys_var_session_time_zone::check(Session *session, set_var *var) |
1
by brian
clean slate |
1938 |
{
|
1939 |
char buff[MAX_TIME_ZONE_NAME_LENGTH]; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1940 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci); |
1
by brian
clean slate |
1941 |
String *res= var->value->val_str(&str); |
1942 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1943 |
if (!(var->save_result.time_zone= my_tz_find(session, res))) |
1
by brian
clean slate |
1944 |
{
|
1945 |
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL"); |
|
1946 |
return 1; |
|
1947 |
}
|
|
1948 |
return 0; |
|
1949 |
}
|
|
1950 |
||
1951 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1952 |
bool sys_var_session_time_zone::update(Session *session, set_var *var) |
1
by brian
clean slate |
1953 |
{
|
1954 |
/* We are using Time_zone object found during check() phase. */
|
|
1955 |
if (var->type == OPT_GLOBAL) |
|
1956 |
{
|
|
1957 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1958 |
global_system_variables.time_zone= var->save_result.time_zone; |
|
1959 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1960 |
}
|
|
1961 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1962 |
session->variables.time_zone= var->save_result.time_zone; |
1
by brian
clean slate |
1963 |
return 0; |
1964 |
}
|
|
1965 |
||
1966 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1967 |
unsigned char *sys_var_session_time_zone::value_ptr(Session *session, |
1968 |
enum_var_type type, |
|
1969 |
LEX_STRING *) |
|
1
by brian
clean slate |
1970 |
{
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1971 |
/*
|
1
by brian
clean slate |
1972 |
We can use ptr() instead of c_ptr() here because String contaning
|
1973 |
time zone name is guaranteed to be zero ended.
|
|
1974 |
*/
|
|
1975 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
1976 |
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr()); |
1
by brian
clean slate |
1977 |
else
|
1978 |
{
|
|
1979 |
/*
|
|
1980 |
This is an ugly fix for replication: we don't replicate properly queries
|
|
1981 |
invoking system variables' values to update tables; but
|
|
1982 |
CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
|
|
1983 |
replicable (i.e. we tell the binlog code to store the session
|
|
1984 |
timezone). If it's the global value which was used we can't replicate
|
|
1985 |
(binlog code stores session value only).
|
|
1986 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1987 |
return (unsigned char *)(session->variables.time_zone->get_name()->ptr()); |
1
by brian
clean slate |
1988 |
}
|
1989 |
}
|
|
1990 |
||
1991 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1992 |
void sys_var_session_time_zone::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1993 |
{
|
1994 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1995 |
if (type == OPT_GLOBAL) |
|
1996 |
{
|
|
1997 |
if (default_tz_name) |
|
1998 |
{
|
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1999 |
String str(default_tz_name, &my_charset_utf8_general_ci); |
1
by brian
clean slate |
2000 |
/*
|
2001 |
We are guaranteed to find this time zone since its existence
|
|
2002 |
is checked during start-up.
|
|
2003 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2004 |
global_system_variables.time_zone= my_tz_find(session, &str); |
1
by brian
clean slate |
2005 |
}
|
2006 |
else
|
|
2007 |
global_system_variables.time_zone= my_tz_SYSTEM; |
|
2008 |
}
|
|
2009 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2010 |
session->variables.time_zone= global_system_variables.time_zone; |
1
by brian
clean slate |
2011 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
2012 |
}
|
|
2013 |
||
2014 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2015 |
bool sys_var_session_lc_time_names::check(Session *, set_var *var) |
1
by brian
clean slate |
2016 |
{
|
2017 |
MY_LOCALE *locale_match; |
|
2018 |
||
2019 |
if (var->value->result_type() == INT_RESULT) |
|
2020 |
{
|
|
2021 |
if (!(locale_match= my_locale_by_number((uint) var->value->val_int()))) |
|
2022 |
{
|
|
2023 |
char buf[20]; |
|
2024 |
int10_to_str((int) var->value->val_int(), buf, -10); |
|
2025 |
my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf); |
|
2026 |
return 1; |
|
2027 |
}
|
|
2028 |
}
|
|
2029 |
else // STRING_RESULT |
|
2030 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2031 |
char buff[6]; |
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
2032 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res; |
1
by brian
clean slate |
2033 |
if (!(res=var->value->val_str(&str))) |
2034 |
{
|
|
2035 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); |
|
2036 |
return 1; |
|
2037 |
}
|
|
2038 |
const char *locale_str= res->c_ptr(); |
|
2039 |
if (!(locale_match= my_locale_by_name(locale_str))) |
|
2040 |
{
|
|
2041 |
my_printf_error(ER_UNKNOWN_ERROR, |
|
2042 |
"Unknown locale: '%s'", MYF(0), locale_str); |
|
2043 |
return 1; |
|
2044 |
}
|
|
2045 |
}
|
|
2046 |
||
2047 |
var->save_result.locale_value= locale_match; |
|
2048 |
return 0; |
|
2049 |
}
|
|
2050 |
||
2051 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2052 |
bool sys_var_session_lc_time_names::update(Session *session, set_var *var) |
1
by brian
clean slate |
2053 |
{
|
2054 |
if (var->type == OPT_GLOBAL) |
|
2055 |
global_system_variables.lc_time_names= var->save_result.locale_value; |
|
2056 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2057 |
session->variables.lc_time_names= var->save_result.locale_value; |
1
by brian
clean slate |
2058 |
return 0; |
2059 |
}
|
|
2060 |
||
2061 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2062 |
unsigned char *sys_var_session_lc_time_names::value_ptr(Session *session, |
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2063 |
enum_var_type type, |
2064 |
LEX_STRING *) |
|
1
by brian
clean slate |
2065 |
{
|
2066 |
return type == OPT_GLOBAL ? |
|
481
by Brian Aker
Remove all of uchar. |
2067 |
(unsigned char *) global_system_variables.lc_time_names->name : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2068 |
(unsigned char *) session->variables.lc_time_names->name; |
1
by brian
clean slate |
2069 |
}
|
2070 |
||
2071 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2072 |
void sys_var_session_lc_time_names::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
2073 |
{
|
2074 |
if (type == OPT_GLOBAL) |
|
2075 |
global_system_variables.lc_time_names= my_default_lc_time_names; |
|
2076 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2077 |
session->variables.lc_time_names= global_system_variables.lc_time_names; |
1
by brian
clean slate |
2078 |
}
|
2079 |
||
2080 |
/*
|
|
2081 |
Handling of microseoncds given as seconds.part_seconds
|
|
2082 |
||
2083 |
NOTES
|
|
2084 |
The argument to long query time is in seconds in decimal
|
|
151
by Brian Aker
Ulonglong to uint64_t |
2085 |
which is converted to uint64_t integer holding microseconds for storage.
|
1
by brian
clean slate |
2086 |
This is used for handling long_query_time
|
2087 |
*/
|
|
2088 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2089 |
bool sys_var_microseconds::update(Session *session, set_var *var) |
1
by brian
clean slate |
2090 |
{
|
2091 |
double num= var->value->val_real(); |
|
152
by Brian Aker
longlong replacement |
2092 |
int64_t microseconds; |
1
by brian
clean slate |
2093 |
if (num > (double) option_limits->max_value) |
2094 |
num= (double) option_limits->max_value; |
|
2095 |
if (num < (double) option_limits->min_value) |
|
2096 |
num= (double) option_limits->min_value; |
|
152
by Brian Aker
longlong replacement |
2097 |
microseconds= (int64_t) (num * 1000000.0 + 0.5); |
1
by brian
clean slate |
2098 |
if (var->type == OPT_GLOBAL) |
2099 |
{
|
|
2100 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
2101 |
(global_system_variables.*offset)= microseconds; |
|
2102 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
2103 |
}
|
|
2104 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2105 |
session->variables.*offset= microseconds; |
1
by brian
clean slate |
2106 |
return 0; |
2107 |
}
|
|
2108 |
||
2109 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2110 |
void sys_var_microseconds::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
2111 |
{
|
152
by Brian Aker
longlong replacement |
2112 |
int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0); |
1
by brian
clean slate |
2113 |
if (type == OPT_GLOBAL) |
2114 |
{
|
|
2115 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
2116 |
global_system_variables.*offset= microseconds; |
|
2117 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
2118 |
}
|
|
2119 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2120 |
session->variables.*offset= microseconds; |
1
by brian
clean slate |
2121 |
}
|
2122 |
||
2123 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2124 |
unsigned char *sys_var_microseconds::value_ptr(Session *session, |
2125 |
enum_var_type type, |
|
2126 |
LEX_STRING *) |
|
1
by brian
clean slate |
2127 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2128 |
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ? |
1
by brian
clean slate |
2129 |
global_system_variables.*offset : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2130 |
session->variables.*offset) / 1000000.0; |
2131 |
return (unsigned char*) &session->tmp_double_value; |
|
1
by brian
clean slate |
2132 |
}
|
2133 |
||
2134 |
||
2135 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2136 |
Functions to update session->options bits
|
1
by brian
clean slate |
2137 |
*/
|
2138 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2139 |
static bool set_option_bit(Session *session, set_var *var) |
1
by brian
clean slate |
2140 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2141 |
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var); |
576
by Brian Aker
ulong conversion work |
2142 |
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2143 |
session->options&= ~sys_var->bit_flag; |
1
by brian
clean slate |
2144 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2145 |
session->options|= sys_var->bit_flag; |
1
by brian
clean slate |
2146 |
return 0; |
2147 |
}
|
|
2148 |
||
2149 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2150 |
static bool set_option_autocommit(Session *session, set_var *var) |
1
by brian
clean slate |
2151 |
{
|
2152 |
/* The test is negative as the flag we use is NOT autocommit */
|
|
2153 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2154 |
uint64_t org_options= session->options; |
1
by brian
clean slate |
2155 |
|
576
by Brian Aker
ulong conversion work |
2156 |
if (var->save_result.uint32_t_value != 0) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2157 |
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag; |
1
by brian
clean slate |
2158 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2159 |
session->options|= ((sys_var_session_bit*) var->var)->bit_flag; |
1
by brian
clean slate |
2160 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2161 |
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT) |
1
by brian
clean slate |
2162 |
{
|
2163 |
if ((org_options & OPTION_NOT_AUTOCOMMIT)) |
|
2164 |
{
|
|
2165 |
/* We changed to auto_commit mode */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2166 |
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG); |
2167 |
session->transaction.all.modified_non_trans_table= false; |
|
2168 |
session->server_status|= SERVER_STATUS_AUTOCOMMIT; |
|
2169 |
if (ha_commit(session)) |
|
1
by brian
clean slate |
2170 |
return 1; |
2171 |
}
|
|
2172 |
else
|
|
2173 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2174 |
session->transaction.all.modified_non_trans_table= false; |
2175 |
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT; |
|
1
by brian
clean slate |
2176 |
}
|
2177 |
}
|
|
2178 |
return 0; |
|
2179 |
}
|
|
2180 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2181 |
static int check_log_update(Session *, set_var *) |
1
by brian
clean slate |
2182 |
{
|
2183 |
return 0; |
|
2184 |
}
|
|
2185 |
||
2186 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2187 |
static int check_pseudo_thread_id(Session *, set_var *var) |
1
by brian
clean slate |
2188 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
2189 |
var->save_result.uint64_t_value= var->value->val_int(); |
1
by brian
clean slate |
2190 |
return 0; |
2191 |
}
|
|
2192 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2193 |
static unsigned char *get_warning_count(Session *session) |
1
by brian
clean slate |
2194 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2195 |
session->sys_var_tmp.long_value= |
626
by Brian Aker
More of the same (ulong/64) |
2196 |
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] + |
2197 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] + |
|
2198 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_WARN]); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2199 |
return (unsigned char*) &session->sys_var_tmp.long_value; |
1
by brian
clean slate |
2200 |
}
|
2201 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2202 |
static unsigned char *get_error_count(Session *session) |
1
by brian
clean slate |
2203 |
{
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2204 |
session->sys_var_tmp.long_value= |
626
by Brian Aker
More of the same (ulong/64) |
2205 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR]; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2206 |
return (unsigned char*) &session->sys_var_tmp.long_value; |
1
by brian
clean slate |
2207 |
}
|
2208 |
||
2209 |
||
2210 |
/**
|
|
2211 |
Get the tmpdir that was specified or chosen by default.
|
|
2212 |
||
2213 |
This is necessary because if the user does not specify a temporary
|
|
2214 |
directory via the command line, one is chosen based on the environment
|
|
575.4.3
by ysano
Rename mysql to drizzle. |
2215 |
or system defaults. But we can't just always use drizzle_tmpdir, because
|
1
by brian
clean slate |
2216 |
that is actually a call to my_tmpdir() which cycles among possible
|
2217 |
temporary directories.
|
|
2218 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2219 |
@param session thread handle
|
1
by brian
clean slate |
2220 |
|
2221 |
@retval
|
|
2222 |
ptr pointer to NUL-terminated string
|
|
2223 |
*/
|
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2224 |
static unsigned char *get_tmpdir(Session *) |
1
by brian
clean slate |
2225 |
{
|
680
by Brian Aker
Remove locks around temp tables for searching tmp directory path. |
2226 |
assert(drizzle_tmpdir); |
575.4.3
by ysano
Rename mysql to drizzle. |
2227 |
return (unsigned char*)drizzle_tmpdir; |
1
by brian
clean slate |
2228 |
}
|
2229 |
||
2230 |
/****************************************************************************
|
|
2231 |
Main handling of variables:
|
|
2232 |
- Initialisation
|
|
2233 |
- Searching during parsing
|
|
2234 |
- Update loop
|
|
2235 |
****************************************************************************/
|
|
2236 |
||
2237 |
/**
|
|
2238 |
Find variable name in option my_getopt structure used for
|
|
2239 |
command line args.
|
|
2240 |
||
2241 |
@param opt option structure array to search in
|
|
2242 |
@param name variable name
|
|
2243 |
||
2244 |
@retval
|
|
2245 |
0 Error
|
|
2246 |
@retval
|
|
2247 |
ptr pointer to option structure
|
|
2248 |
*/
|
|
2249 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2250 |
static struct my_option *find_option(struct my_option *opt, const char *name) |
1
by brian
clean slate |
2251 |
{
|
482
by Brian Aker
Remove uint. |
2252 |
uint32_t length=strlen(name); |
1
by brian
clean slate |
2253 |
for (; opt->name; opt++) |
2254 |
{
|
|
2255 |
if (!getopt_compare_strings(opt->name, name, length) && |
|
2256 |
!opt->name[length]) |
|
2257 |
{
|
|
2258 |
/*
|
|
2259 |
Only accept the option if one can set values through it.
|
|
2260 |
If not, there is no default value or limits in the option.
|
|
2261 |
*/
|
|
2262 |
return (opt->value) ? opt : 0; |
|
2263 |
}
|
|
2264 |
}
|
|
2265 |
return 0; |
|
2266 |
}
|
|
2267 |
||
2268 |
||
2269 |
/**
|
|
2270 |
Return variable name and length for hashing of variables.
|
|
2271 |
*/
|
|
2272 |
||
481
by Brian Aker
Remove all of uchar. |
2273 |
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length, |
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2274 |
bool) |
1
by brian
clean slate |
2275 |
{
|
2276 |
*length= var->name_length; |
|
481
by Brian Aker
Remove all of uchar. |
2277 |
return (unsigned char*) var->name; |
1
by brian
clean slate |
2278 |
}
|
2279 |
||
2280 |
||
2281 |
/*
|
|
2282 |
Add variables to the dynamic hash of system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2283 |
|
1
by brian
clean slate |
2284 |
SYNOPSIS
|
2285 |
mysql_add_sys_var_chain()
|
|
2286 |
first Pointer to first system variable to add
|
|
2287 |
long_opt (optional)command line arguments may be tied for limit checks.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2288 |
|
1
by brian
clean slate |
2289 |
RETURN VALUES
|
2290 |
0 SUCCESS
|
|
2291 |
otherwise FAILURE
|
|
2292 |
*/
|
|
2293 |
||
2294 |
||
2295 |
int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options) |
|
2296 |
{
|
|
2297 |
sys_var *var; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2298 |
|
1
by brian
clean slate |
2299 |
/* A write lock should be held on LOCK_system_variables_hash */
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2300 |
|
1
by brian
clean slate |
2301 |
for (var= first; var; var= var->next) |
2302 |
{
|
|
2303 |
var->name_length= strlen(var->name); |
|
2304 |
/* this fails if there is a conflicting variable name. see HASH_UNIQUE */
|
|
481
by Brian Aker
Remove all of uchar. |
2305 |
if (my_hash_insert(&system_variable_hash, (unsigned char*) var)) |
1
by brian
clean slate |
2306 |
goto error; |
2307 |
if (long_options) |
|
2308 |
var->option_limits= find_option(long_options, var->name); |
|
2309 |
}
|
|
2310 |
return 0; |
|
2311 |
||
2312 |
error: |
|
2313 |
for (; first != var; first= first->next) |
|
481
by Brian Aker
Remove all of uchar. |
2314 |
hash_delete(&system_variable_hash, (unsigned char*) first); |
1
by brian
clean slate |
2315 |
return 1; |
2316 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2317 |
|
2318 |
||
1
by brian
clean slate |
2319 |
/*
|
2320 |
Remove variables to the dynamic hash of system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2321 |
|
1
by brian
clean slate |
2322 |
SYNOPSIS
|
2323 |
mysql_del_sys_var_chain()
|
|
2324 |
first Pointer to first system variable to remove
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2325 |
|
1
by brian
clean slate |
2326 |
RETURN VALUES
|
2327 |
0 SUCCESS
|
|
2328 |
otherwise FAILURE
|
|
2329 |
*/
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2330 |
|
1
by brian
clean slate |
2331 |
int mysql_del_sys_var_chain(sys_var *first) |
2332 |
{
|
|
2333 |
int result= 0; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2334 |
|
1
by brian
clean slate |
2335 |
/* A write lock should be held on LOCK_system_variables_hash */
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2336 |
|
1
by brian
clean slate |
2337 |
for (sys_var *var= first; var; var= var->next) |
481
by Brian Aker
Remove all of uchar. |
2338 |
result|= hash_delete(&system_variable_hash, (unsigned char*) var); |
1
by brian
clean slate |
2339 |
|
2340 |
return result; |
|
2341 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2342 |
|
2343 |
||
1
by brian
clean slate |
2344 |
static int show_cmp(SHOW_VAR *a, SHOW_VAR *b) |
2345 |
{
|
|
2346 |
return strcmp(a->name, b->name); |
|
2347 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2348 |
|
2349 |
||
1
by brian
clean slate |
2350 |
/*
|
2351 |
Constructs an array of system variables for display to the user.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2352 |
|
1
by brian
clean slate |
2353 |
SYNOPSIS
|
2354 |
enumerate_sys_vars()
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2355 |
session current thread
|
1
by brian
clean slate |
2356 |
sorted If TRUE, the system variables should be sorted
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2357 |
|
1
by brian
clean slate |
2358 |
RETURN VALUES
|
2359 |
pointer Array of SHOW_VAR elements for display
|
|
2360 |
NULL FAILURE
|
|
2361 |
*/
|
|
2362 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2363 |
SHOW_VAR* enumerate_sys_vars(Session *session, bool sorted) |
1
by brian
clean slate |
2364 |
{
|
2365 |
int count= system_variable_hash.records, i; |
|
2366 |
int fixed_count= fixed_show_vars.elements; |
|
2367 |
int size= sizeof(SHOW_VAR) * (count + fixed_count + 1); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2368 |
SHOW_VAR *result= (SHOW_VAR*) session->alloc(size); |
1
by brian
clean slate |
2369 |
|
2370 |
if (result) |
|
2371 |
{
|
|
2372 |
SHOW_VAR *show= result + fixed_count; |
|
2373 |
memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(SHOW_VAR)); |
|
2374 |
||
2375 |
for (i= 0; i < count; i++) |
|
2376 |
{
|
|
2377 |
sys_var *var= (sys_var*) hash_element(&system_variable_hash, i); |
|
2378 |
show->name= var->name; |
|
2379 |
show->value= (char*) var; |
|
2380 |
show->type= SHOW_SYS; |
|
2381 |
show++; |
|
2382 |
}
|
|
2383 |
||
2384 |
/* sort into order */
|
|
2385 |
if (sorted) |
|
2386 |
my_qsort(result, count + fixed_count, sizeof(SHOW_VAR), |
|
2387 |
(qsort_cmp) show_cmp); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2388 |
|
1
by brian
clean slate |
2389 |
/* make last element empty */
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2390 |
memset(show, 0, sizeof(SHOW_VAR)); |
1
by brian
clean slate |
2391 |
}
|
2392 |
return result; |
|
2393 |
}
|
|
2394 |
||
2395 |
||
656.1.34
by Monty Taylor
Got closer... |
2396 |
NAMED_LIST::NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg, |
2397 |
uint32_t name_length_arg, unsigned char* data_arg) |
|
2398 |
:data(data_arg) |
|
2399 |
{
|
|
2400 |
name.assign(name_arg, name_length_arg); |
|
2401 |
links->push_back(this); |
|
2402 |
}
|
|
2403 |
||
2404 |
||
2405 |
bool NAMED_LIST::cmp(const char *name_cmp, uint32_t length) |
|
2406 |
{
|
|
2407 |
return length == name.length() && !name.compare(name_cmp); |
|
2408 |
}
|
|
2409 |
||
2410 |
||
1
by brian
clean slate |
2411 |
/*
|
2412 |
Initialize the system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2413 |
|
1
by brian
clean slate |
2414 |
SYNOPSIS
|
2415 |
set_var_init()
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2416 |
|
1
by brian
clean slate |
2417 |
RETURN VALUES
|
2418 |
0 SUCCESS
|
|
2419 |
otherwise FAILURE
|
|
2420 |
*/
|
|
2421 |
||
2422 |
int set_var_init() |
|
2423 |
{
|
|
482
by Brian Aker
Remove uint. |
2424 |
uint32_t count= 0; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2425 |
|
1
by brian
clean slate |
2426 |
for (sys_var *var=vars.first; var; var= var->next, count++) {}; |
2427 |
||
2428 |
if (my_init_dynamic_array(&fixed_show_vars, sizeof(SHOW_VAR), |
|
2429 |
FIXED_VARS_SIZE + 64, 64)) |
|
2430 |
goto error; |
|
2431 |
||
2432 |
fixed_show_vars.elements= FIXED_VARS_SIZE; |
|
2433 |
memcpy(fixed_show_vars.buffer, fixed_vars, sizeof(fixed_vars)); |
|
2434 |
||
2435 |
if (hash_init(&system_variable_hash, system_charset_info, count, 0, |
|
2436 |
0, (hash_get_key) get_sys_var_length, 0, HASH_UNIQUE)) |
|
2437 |
goto error; |
|
2438 |
||
2439 |
vars.last->next= NULL; |
|
2440 |
if (mysql_add_sys_var_chain(vars.first, my_long_options)) |
|
2441 |
goto error; |
|
2442 |
||
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2443 |
return(0); |
1
by brian
clean slate |
2444 |
|
2445 |
error: |
|
2446 |
fprintf(stderr, "failed to initialize system variables"); |
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2447 |
return(1); |
1
by brian
clean slate |
2448 |
}
|
2449 |
||
2450 |
||
2451 |
void set_var_free() |
|
2452 |
{
|
|
2453 |
hash_free(&system_variable_hash); |
|
2454 |
delete_dynamic(&fixed_show_vars); |
|
2455 |
}
|
|
2456 |
||
2457 |
||
2458 |
/*
|
|
2459 |
Add elements to the dynamic list of read-only system variables.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2460 |
|
1
by brian
clean slate |
2461 |
SYNOPSIS
|
2462 |
mysql_append_static_vars()
|
|
2463 |
show_vars Pointer to start of array
|
|
2464 |
count Number of elements
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2465 |
|
1
by brian
clean slate |
2466 |
RETURN VALUES
|
2467 |
0 SUCCESS
|
|
2468 |
otherwise FAILURE
|
|
2469 |
*/
|
|
482
by Brian Aker
Remove uint. |
2470 |
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count) |
1
by brian
clean slate |
2471 |
{
|
2472 |
for (; count > 0; count--, show_vars++) |
|
481
by Brian Aker
Remove all of uchar. |
2473 |
if (insert_dynamic(&fixed_show_vars, (unsigned char*) show_vars)) |
1
by brian
clean slate |
2474 |
return 1; |
2475 |
return 0; |
|
2476 |
}
|
|
2477 |
||
2478 |
||
2479 |
/**
|
|
2480 |
Find a user set-table variable.
|
|
2481 |
||
2482 |
@param str Name of system variable to find
|
|
2483 |
@param length Length of variable. zero means that we should use strlen()
|
|
2484 |
on the variable
|
|
2485 |
@param no_error Refuse to emit an error, even if one occurred.
|
|
2486 |
||
2487 |
@retval
|
|
2488 |
pointer pointer to variable definitions
|
|
2489 |
@retval
|
|
2490 |
0 Unknown variable (error message is given)
|
|
2491 |
*/
|
|
2492 |
||
482
by Brian Aker
Remove uint. |
2493 |
sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error) |
1
by brian
clean slate |
2494 |
{
|
2495 |
sys_var *var; |
|
2496 |
||
2497 |
/*
|
|
2498 |
This function is only called from the sql_plugin.cc.
|
|
2499 |
A lock on LOCK_system_variable_hash should be held
|
|
2500 |
*/
|
|
2501 |
var= (sys_var*) hash_search(&system_variable_hash, |
|
481
by Brian Aker
Remove all of uchar. |
2502 |
(unsigned char*) str, length ? length : strlen(str)); |
1
by brian
clean slate |
2503 |
if (!(var || no_error)) |
2504 |
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); |
|
2505 |
||
2506 |
return var; |
|
2507 |
}
|
|
2508 |
||
2509 |
||
2510 |
/**
|
|
2511 |
Execute update of all variables.
|
|
2512 |
||
2513 |
First run a check of all variables that all updates will go ok.
|
|
2514 |
If yes, then execute all updates, returning an error if any one failed.
|
|
2515 |
||
2516 |
This should ensure that in all normal cases none all or variables are
|
|
2517 |
updated.
|
|
2518 |
||
520.1.21
by Brian Aker
THD -> Session rename |
2519 |
@param Session Thread id
|
1
by brian
clean slate |
2520 |
@param var_list List of variables to update
|
2521 |
||
2522 |
@retval
|
|
2523 |
0 ok
|
|
2524 |
@retval
|
|
2525 |
1 ERROR, message sent (normally no variables was updated)
|
|
2526 |
@retval
|
|
2527 |
-1 ERROR, message not sent
|
|
2528 |
*/
|
|
2529 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2530 |
int sql_set_variables(Session *session, List<set_var_base> *var_list) |
1
by brian
clean slate |
2531 |
{
|
2532 |
int error; |
|
2533 |
List_iterator_fast<set_var_base> it(*var_list); |
|
2534 |
||
2535 |
set_var_base *var; |
|
2536 |
while ((var=it++)) |
|
2537 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2538 |
if ((error= var->check(session))) |
1
by brian
clean slate |
2539 |
goto err; |
2540 |
}
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2541 |
if (!(error= test(session->is_error()))) |
1
by brian
clean slate |
2542 |
{
|
2543 |
it.rewind(); |
|
2544 |
while ((var= it++)) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2545 |
error|= var->update(session); // Returns 0, -1 or 1 |
1
by brian
clean slate |
2546 |
}
|
2547 |
||
2548 |
err: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2549 |
free_underlaid_joins(session, &session->lex->select_lex); |
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2550 |
return(error); |
1
by brian
clean slate |
2551 |
}
|
2552 |
||
2553 |
||
2554 |
/*****************************************************************************
|
|
2555 |
Functions to handle SET mysql_internal_variable=const_expr
|
|
2556 |
*****************************************************************************/
|
|
2557 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2558 |
int set_var::check(Session *session) |
1
by brian
clean slate |
2559 |
{
|
2560 |
if (var->is_readonly()) |
|
2561 |
{
|
|
2562 |
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->name, "read only"); |
|
2563 |
return -1; |
|
2564 |
}
|
|
2565 |
if (var->check_type(type)) |
|
2566 |
{
|
|
2567 |
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE; |
|
2568 |
my_error(err, MYF(0), var->name); |
|
2569 |
return -1; |
|
2570 |
}
|
|
2571 |
/* value is a NULL pointer if we are using SET ... = DEFAULT */
|
|
2572 |
if (!value) |
|
2573 |
{
|
|
2574 |
if (var->check_default(type)) |
|
2575 |
{
|
|
2576 |
my_error(ER_NO_DEFAULT, MYF(0), var->name); |
|
2577 |
return -1; |
|
2578 |
}
|
|
2579 |
return 0; |
|
2580 |
}
|
|
2581 |
||
2582 |
if ((!value->fixed && |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2583 |
value->fix_fields(session, &value)) || value->check_cols(1)) |
1
by brian
clean slate |
2584 |
return -1; |
2585 |
if (var->check_update_type(value->result_type())) |
|
2586 |
{
|
|
2587 |
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name); |
|
2588 |
return -1; |
|
2589 |
}
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2590 |
return var->check(session, this) ? -1 : 0; |
1
by brian
clean slate |
2591 |
}
|
2592 |
||
2593 |
/**
|
|
2594 |
Update variable
|
|
2595 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2596 |
@param session thread handler
|
1
by brian
clean slate |
2597 |
@returns 0|1 ok or ERROR
|
2598 |
||
2599 |
@note ERROR can be only due to abnormal operations involving
|
|
2600 |
the server's execution evironment such as
|
|
2601 |
out of memory, hard disk failure or the computer blows up.
|
|
2602 |
Consider set_var::check() method if there is a need to return
|
|
2603 |
an error due to logics.
|
|
2604 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2605 |
int set_var::update(Session *session) |
1
by brian
clean slate |
2606 |
{
|
2607 |
if (!value) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2608 |
var->set_default(session, type); |
2609 |
else if (var->update(session, this)) |
|
1
by brian
clean slate |
2610 |
return -1; // should never happen |
2611 |
if (var->after_update) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2612 |
(*var->after_update)(session, type); |
1
by brian
clean slate |
2613 |
return 0; |
2614 |
}
|
|
2615 |
||
2616 |
||
2617 |
/*****************************************************************************
|
|
2618 |
Functions to handle SET @user_variable=const_expr
|
|
2619 |
*****************************************************************************/
|
|
2620 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2621 |
int set_var_user::check(Session *session) |
1
by brian
clean slate |
2622 |
{
|
2623 |
/*
|
|
2624 |
Item_func_set_user_var can't substitute something else on its place =>
|
|
2625 |
0 can be passed as last argument (reference on item)
|
|
2626 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2627 |
return (user_var_item->fix_fields(session, (Item**) 0) || |
1
by brian
clean slate |
2628 |
user_var_item->check(0)) ? -1 : 0; |
2629 |
}
|
|
2630 |
||
2631 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2632 |
int set_var_user::update(Session *) |
1
by brian
clean slate |
2633 |
{
|
2634 |
if (user_var_item->update()) |
|
2635 |
{
|
|
2636 |
/* Give an error if it's not given already */
|
|
2637 |
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0)); |
|
2638 |
return -1; |
|
2639 |
}
|
|
2640 |
return 0; |
|
2641 |
}
|
|
2642 |
||
2643 |
/****************************************************************************
|
|
2644 |
Functions to handle table_type
|
|
2645 |
****************************************************************************/
|
|
2646 |
||
2647 |
/* Based upon sys_var::check_enum() */
|
|
2648 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2649 |
bool sys_var_session_storage_engine::check(Session *session, set_var *var) |
1
by brian
clean slate |
2650 |
{
|
2651 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
2652 |
const char *value; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
2653 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res; |
1
by brian
clean slate |
2654 |
|
2655 |
var->save_result.plugin= NULL; |
|
2656 |
if (var->value->result_type() == STRING_RESULT) |
|
2657 |
{
|
|
2658 |
LEX_STRING engine_name; |
|
2659 |
handlerton *hton; |
|
2660 |
if (!(res=var->value->val_str(&str)) || |
|
2661 |
!(engine_name.str= (char *)res->ptr()) || |
|
2662 |
!(engine_name.length= res->length()) || |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2663 |
!(var->save_result.plugin= ha_resolve_by_name(session, &engine_name)) || |
411
by Brian Aker
Removed legacy bits around enum. |
2664 |
!(hton= plugin_data(var->save_result.plugin, handlerton *))) |
1
by brian
clean slate |
2665 |
{
|
2666 |
value= res ? res->c_ptr() : "NULL"; |
|
2667 |
goto err; |
|
2668 |
}
|
|
2669 |
return 0; |
|
2670 |
}
|
|
2671 |
value= "unknown"; |
|
2672 |
||
2673 |
err: |
|
2674 |
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value); |
|
2675 |
return 1; |
|
2676 |
}
|
|
2677 |
||
2678 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2679 |
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session, |
2680 |
enum_var_type type, |
|
2681 |
LEX_STRING *) |
|
1
by brian
clean slate |
2682 |
{
|
481
by Brian Aker
Remove all of uchar. |
2683 |
unsigned char* result; |
1
by brian
clean slate |
2684 |
handlerton *hton; |
2685 |
LEX_STRING *engine_name; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2686 |
plugin_ref plugin= session->variables.*offset; |
1
by brian
clean slate |
2687 |
if (type == OPT_GLOBAL) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2688 |
plugin= my_plugin_lock(session, &(global_system_variables.*offset)); |
1
by brian
clean slate |
2689 |
hton= plugin_data(plugin, handlerton*); |
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
2690 |
engine_name= ha_storage_engine_name(hton); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2691 |
result= (unsigned char *) session->strmake(engine_name->str, engine_name->length); |
1
by brian
clean slate |
2692 |
if (type == OPT_GLOBAL) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2693 |
plugin_unlock(session, plugin); |
1
by brian
clean slate |
2694 |
return result; |
2695 |
}
|
|
2696 |
||
2697 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2698 |
void sys_var_session_storage_engine::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
2699 |
{
|
2700 |
plugin_ref old_value, new_value, *value; |
|
2701 |
if (type == OPT_GLOBAL) |
|
2702 |
{
|
|
2703 |
value= &(global_system_variables.*offset); |
|
2704 |
new_value= ha_lock_engine(NULL, myisam_hton); |
|
2705 |
}
|
|
2706 |
else
|
|
2707 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2708 |
value= &(session->variables.*offset); |
1
by brian
clean slate |
2709 |
new_value= my_plugin_lock(NULL, &(global_system_variables.*offset)); |
2710 |
}
|
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2711 |
assert(new_value); |
1
by brian
clean slate |
2712 |
old_value= *value; |
2713 |
*value= new_value; |
|
2714 |
plugin_unlock(NULL, old_value); |
|
2715 |
}
|
|
2716 |
||
2717 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2718 |
bool sys_var_session_storage_engine::update(Session *session, set_var *var) |
1
by brian
clean slate |
2719 |
{
|
2720 |
plugin_ref *value= &(global_system_variables.*offset), old_value; |
|
2721 |
if (var->type != OPT_GLOBAL) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2722 |
value= &(session->variables.*offset); |
1
by brian
clean slate |
2723 |
old_value= *value; |
2724 |
if (old_value != var->save_result.plugin) |
|
2725 |
{
|
|
2726 |
*value= my_plugin_lock(NULL, &var->save_result.plugin); |
|
2727 |
plugin_unlock(NULL, old_value); |
|
2728 |
}
|
|
2729 |
return 0; |
|
2730 |
}
|
|
2731 |
||
2732 |
bool
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2733 |
sys_var_session_optimizer_switch:: |
617
by Brian Aker
ulong fixes |
2734 |
symbolic_mode_representation(Session *session, uint32_t val, LEX_STRING *rep) |
1
by brian
clean slate |
2735 |
{
|
2736 |
char buff[STRING_BUFFER_USUAL_SIZE*8]; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
2737 |
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci); |
1
by brian
clean slate |
2738 |
|
2739 |
tmp.length(0); |
|
2740 |
||
482
by Brian Aker
Remove uint. |
2741 |
for (uint32_t i= 0; val; val>>= 1, i++) |
1
by brian
clean slate |
2742 |
{
|
2743 |
if (val & 1) |
|
2744 |
{
|
|
2745 |
tmp.append(optimizer_switch_typelib.type_names[i], |
|
2746 |
optimizer_switch_typelib.type_lengths[i]); |
|
2747 |
tmp.append(','); |
|
2748 |
}
|
|
2749 |
}
|
|
2750 |
||
2751 |
if (tmp.length()) |
|
2752 |
tmp.length(tmp.length() - 1); /* trim the trailing comma */ |
|
2753 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2754 |
rep->str= session->strmake(tmp.ptr(), tmp.length()); |
1
by brian
clean slate |
2755 |
|
2756 |
rep->length= rep->str ? tmp.length() : 0; |
|
2757 |
||
2758 |
return rep->length != tmp.length(); |
|
2759 |
}
|
|
2760 |
||
2761 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2762 |
unsigned char *sys_var_session_optimizer_switch::value_ptr(Session *session, |
2763 |
enum_var_type type, |
|
2764 |
LEX_STRING *) |
|
1
by brian
clean slate |
2765 |
{
|
2766 |
LEX_STRING opts; |
|
151
by Brian Aker
Ulonglong to uint64_t |
2767 |
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2768 |
session->variables.*offset); |
2769 |
(void) symbolic_mode_representation(session, val, &opts); |
|
481
by Brian Aker
Remove all of uchar. |
2770 |
return (unsigned char *) opts.str; |
1
by brian
clean slate |
2771 |
}
|
2772 |
||
2773 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2774 |
void sys_var_session_optimizer_switch::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
2775 |
{
|
2776 |
if (type == OPT_GLOBAL) |
|
2777 |
global_system_variables.*offset= 0; |
|
2778 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2779 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
2780 |
}
|
2781 |
||
2782 |
||
2783 |
/****************************************************************************
|
|
2784 |
Named list handling
|
|
2785 |
****************************************************************************/
|
|
2786 |
||
482
by Brian Aker
Remove uint. |
2787 |
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length, |
1
by brian
clean slate |
2788 |
NAMED_LIST **found) |
2789 |
{
|
|
2790 |
I_List_iterator<NAMED_LIST> it(*list); |
|
2791 |
NAMED_LIST *element; |
|
2792 |
while ((element= it++)) |
|
2793 |
{
|
|
2794 |
if (element->cmp(name, length)) |
|
2795 |
{
|
|
2796 |
if (found) |
|
2797 |
*found= element; |
|
2798 |
return element->data; |
|
2799 |
}
|
|
2800 |
}
|
|
2801 |
return 0; |
|
2802 |
}
|
|
2803 |
||
2804 |
||
2805 |
void delete_elements(I_List<NAMED_LIST> *list, |
|
481
by Brian Aker
Remove all of uchar. |
2806 |
void (*free_element)(const char *name, unsigned char*)) |
1
by brian
clean slate |
2807 |
{
|
2808 |
NAMED_LIST *element; |
|
2809 |
while ((element= list->get())) |
|
2810 |
{
|
|
656.1.34
by Monty Taylor
Got closer... |
2811 |
(*free_element)(element->name.c_str(), element->data); |
1
by brian
clean slate |
2812 |
delete element; |
2813 |
}
|
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2814 |
return; |
1
by brian
clean slate |
2815 |
}
|
2816 |
||
2817 |
||
2818 |
/* Key cache functions */
|
|
2819 |
||
482
by Brian Aker
Remove uint. |
2820 |
static KEY_CACHE *create_key_cache(const char *name, uint32_t length) |
1
by brian
clean slate |
2821 |
{
|
2822 |
KEY_CACHE *key_cache; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2823 |
|
641.3.8
by Monty Taylor
Removed my_malloc from drizzled. |
2824 |
if ((key_cache= (KEY_CACHE*) malloc(sizeof(KEY_CACHE)))) |
1
by brian
clean slate |
2825 |
{
|
641.3.8
by Monty Taylor
Removed my_malloc from drizzled. |
2826 |
memset(key_cache, 0, sizeof(KEY_CACHE)); |
481
by Brian Aker
Remove all of uchar. |
2827 |
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache)) |
1
by brian
clean slate |
2828 |
{
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2829 |
free((char*) key_cache); |
1
by brian
clean slate |
2830 |
key_cache= 0; |
2831 |
}
|
|
2832 |
else
|
|
2833 |
{
|
|
2834 |
/*
|
|
2835 |
Set default values for a key cache
|
|
2836 |
The values in dflt_key_cache_var is set by my_getopt() at startup
|
|
2837 |
||
2838 |
We don't set 'buff_size' as this is used to enable the key cache
|
|
2839 |
*/
|
|
2840 |
key_cache->param_block_size= dflt_key_cache_var.param_block_size; |
|
2841 |
key_cache->param_division_limit= dflt_key_cache_var.param_division_limit; |
|
2842 |
key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold; |
|
2843 |
}
|
|
2844 |
}
|
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2845 |
return(key_cache); |
1
by brian
clean slate |
2846 |
}
|
2847 |
||
2848 |
||
482
by Brian Aker
Remove uint. |
2849 |
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length) |
1
by brian
clean slate |
2850 |
{
|
2851 |
LEX_STRING key_cache_name; |
|
2852 |
KEY_CACHE *key_cache; |
|
2853 |
||
2854 |
key_cache_name.str= (char *) name; |
|
2855 |
key_cache_name.length= length; |
|
2856 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
2857 |
if (!(key_cache= get_key_cache(&key_cache_name))) |
|
2858 |
key_cache= create_key_cache(name, length); |
|
2859 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
2860 |
return key_cache; |
|
2861 |
}
|
|
2862 |
||
2863 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2864 |
void free_key_cache(const char *, KEY_CACHE *key_cache) |
1
by brian
clean slate |
2865 |
{
|
2866 |
ha_end_key_cache(key_cache); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
2867 |
free((char*) key_cache); |
1
by brian
clean slate |
2868 |
}
|
2869 |
||
2870 |
||
2871 |
bool process_key_caches(process_key_cache_t func) |
|
2872 |
{
|
|
2873 |
I_List_iterator<NAMED_LIST> it(key_caches); |
|
2874 |
NAMED_LIST *element; |
|
2875 |
||
2876 |
while ((element= it++)) |
|
2877 |
{
|
|
2878 |
KEY_CACHE *key_cache= (KEY_CACHE *) element->data; |
|
656.1.34
by Monty Taylor
Got closer... |
2879 |
func(element->name.c_str(), key_cache); |
1
by brian
clean slate |
2880 |
}
|
2881 |
return 0; |
|
2882 |
}
|
|
2883 |
||
2884 |
/****************************************************************************
|
|
2885 |
Used templates
|
|
2886 |
****************************************************************************/
|
|
2887 |
||
2888 |
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
|
|
2889 |
template class List<set_var_base>; |
|
2890 |
template class List_iterator_fast<set_var_base>; |
|
2891 |
template class I_List_iterator<NAMED_LIST>; |
|
2892 |
#endif
|