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 |
/**
|
|
1055.2.17
by Jay Pipes
More style cleanups in Session |
21 |
@file Handling of MySQL SQL variables
|
1
by brian
clean slate |
22 |
|
23 |
@details
|
|
24 |
To add a new variable, one has to do the following:
|
|
25 |
||
26 |
- Use one of the 'sys_var... classes from set_var.h or write a specific
|
|
27 |
one for the variable type.
|
|
28 |
- Define it in the 'variable definition list' in this file.
|
|
29 |
- If the variable is thread specific, add it to 'system_variables' struct.
|
|
30 |
If not, add it to mysqld.cc and an declaration in 'mysql_priv.h'
|
|
31 |
- If the variable should be changed from the command line, add a definition
|
|
32 |
of it in the my_option structure list in mysqld.cc
|
|
33 |
- Don't forget to initialize new fields in global_system_variables and
|
|
34 |
max_system_variables!
|
|
35 |
||
36 |
@todo
|
|
37 |
Add full support for the variable character_set (for 4.1)
|
|
38 |
||
39 |
@note
|
|
40 |
Be careful with var->save_result: sys_var::check() only updates
|
|
151
by Brian Aker
Ulonglong to uint64_t |
41 |
uint64_t_value; so other members of the union are garbage then; to use
|
1
by brian
clean slate |
42 |
them you must first assign a value to them (in specific ::check() for
|
43 |
example).
|
|
44 |
*/
|
|
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. |
45 |
|
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
46 |
#include "config.h" |
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
47 |
#include "drizzled/my_getopt.h" |
992.1.25
by Monty Taylor
Moved myisam to new plugin system. |
48 |
#include <plugin/myisam/myisam.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
49 |
#include <drizzled/error.h> |
538
by Monty Taylor
Moved gettext.h into drizzled in anticipation of the new client lib. |
50 |
#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. |
51 |
#include <drizzled/tztime.h> |
520.6.7
by Monty Taylor
Moved a bunch of crap out of common_includes. |
52 |
#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. |
53 |
#include <drizzled/set_var.h> |
54 |
#include <drizzled/session.h> |
|
55 |
#include <drizzled/sql_base.h> |
|
670.2.4
by Monty Taylor
Removed more stuff from the headers. |
56 |
#include <drizzled/lock.h> |
642.1.16
by Lee
header file clean up |
57 |
#include <drizzled/item/uint.h> |
642.1.20
by Lee
header file clean up |
58 |
#include <drizzled/item/null.h> |
670.1.22
by Monty Taylor
Merged from Lee. |
59 |
#include <drizzled/item/float.h> |
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
60 |
#include <drizzled/plugin.h> |
1241.9.12
by Monty Taylor
Trims more out of server_includes.h. |
61 |
#include "drizzled/version.h" |
62 |
#include "drizzled/strfunc.h" |
|
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
63 |
#include "drizzled/internal/m_string.h" |
1241.9.31
by Monty Taylor
Moved global pthread variables into their own header. |
64 |
#include "drizzled/pthread_globals.h" |
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
65 |
#include "drizzled/charset.h" |
1
by brian
clean slate |
66 |
|
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
67 |
#include <map> |
68 |
#include <algorithm> |
|
69 |
||
70 |
using namespace std; |
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
71 |
using namespace drizzled; |
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
72 |
|
1241.9.32
by Monty Taylor
Moved global myisam and heap pointers out of server_includes. |
73 |
extern plugin::StorageEngine *myisam_engine; |
1241.9.27
by Monty Taylor
Removed mysys/m_sys.h from server_includes.h. |
74 |
|
75 |
extern struct my_option my_long_options[]; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
76 |
extern const CHARSET_INFO *character_set_filesystem; |
629.2.7
by Monty Taylor
Fixed a couple of memory buffer size issues. |
77 |
extern size_t my_thread_stack_size; |
1
by brian
clean slate |
78 |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
79 |
class sys_var_pluginvar; |
1
by brian
clean slate |
80 |
static DYNAMIC_ARRAY fixed_show_vars; |
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
81 |
typedef map<string, sys_var *> SystemVariableMap; |
82 |
static SystemVariableMap system_variable_map; |
|
670.2.4
by Monty Taylor
Removed more stuff from the headers. |
83 |
extern char *opt_drizzle_tmpdir; |
1
by brian
clean slate |
84 |
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
85 |
extern TYPELIB tx_isolation_typelib; |
86 |
||
461
by Monty Taylor
Removed NullS. bu-bye. |
87 |
const char *bool_type_names[]= { "OFF", "ON", NULL }; |
1
by brian
clean slate |
88 |
TYPELIB bool_typelib= |
89 |
{
|
|
90 |
array_elements(bool_type_names)-1, "", bool_type_names, NULL |
|
91 |
};
|
|
92 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
93 |
static bool set_option_bit(Session *session, set_var *var); |
94 |
static bool set_option_autocommit(Session *session, set_var *var); |
|
95 |
static int check_pseudo_thread_id(Session *session, set_var *var); |
|
96 |
static int check_tx_isolation(Session *session, set_var *var); |
|
97 |
static void fix_tx_isolation(Session *session, enum_var_type type); |
|
98 |
static int check_completion_type(Session *session, set_var *var); |
|
99 |
static void fix_completion_type(Session *session, enum_var_type type); |
|
100 |
static void fix_max_join_size(Session *session, enum_var_type type); |
|
101 |
static void fix_session_mem_root(Session *session, enum_var_type type); |
|
102 |
static void fix_trans_mem_root(Session *session, enum_var_type type); |
|
103 |
static void fix_server_id(Session *session, enum_var_type type); |
|
520.1.21
by Brian Aker
THD -> Session rename |
104 |
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *); |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
105 |
static bool get_unsigned32(Session *session, set_var *var); |
106 |
static bool get_unsigned64(Session *session, set_var *var); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
107 |
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
108 |
const std::string &name, int64_t val); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
109 |
static unsigned char *get_error_count(Session *session); |
110 |
static unsigned char *get_warning_count(Session *session); |
|
111 |
static unsigned char *get_tmpdir(Session *session); |
|
1
by brian
clean slate |
112 |
|
113 |
/*
|
|
114 |
Variable definition list
|
|
115 |
||
116 |
These are variables that can be set from the command line, in
|
|
117 |
alphabetic order.
|
|
118 |
||
119 |
The variables are linked into the list. A variable is added to
|
|
120 |
it in the constructor (see sys_var class for details).
|
|
121 |
*/
|
|
122 |
static sys_var_chain vars = { NULL, NULL }; |
|
123 |
||
819.1.1
by Toru Maesaka
Removed the 16bit limitation of auto_increment_(increment|offset) system variables |
124 |
static sys_var_session_uint64_t |
1
by brian
clean slate |
125 |
sys_auto_increment_increment(&vars, "auto_increment_increment", |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
126 |
&SV::auto_increment_increment); |
819.1.1
by Toru Maesaka
Removed the 16bit limitation of auto_increment_(increment|offset) system variables |
127 |
static sys_var_session_uint64_t |
1
by brian
clean slate |
128 |
sys_auto_increment_offset(&vars, "auto_increment_offset", |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
129 |
&SV::auto_increment_offset); |
1
by brian
clean slate |
130 |
|
575.4.1
by ysano
Rename mysql to drizzle. |
131 |
static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home); |
619
by Brian Aker
Removed ulong methods from vars. |
132 |
static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size", |
133 |
&SV::bulk_insert_buff_size); |
|
134 |
static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type", |
|
135 |
&SV::completion_type, |
|
136 |
check_completion_type, |
|
137 |
fix_completion_type); |
|
1
by brian
clean slate |
138 |
static sys_var_collation_sv |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
139 |
sys_collation_server(&vars, "collation_server", &SV::collation_server, &default_charset_info); |
575.4.1
by ysano
Rename mysql to drizzle. |
140 |
static sys_var_const_str sys_datadir(&vars, "datadir", drizzle_real_data_home); |
1
by brian
clean slate |
141 |
|
616
by Brian Aker
ulong fixes. |
142 |
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size", |
143 |
&SV::join_buff_size); |
|
1
by brian
clean slate |
144 |
static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size"); |
910.4.18
by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64 |
145 |
static sys_var_key_cache_uint32_t sys_key_cache_block_size(&vars, "key_cache_block_size", |
616
by Brian Aker
ulong fixes. |
146 |
offsetof(KEY_CACHE, |
147 |
param_block_size)); |
|
910.4.18
by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64 |
148 |
static sys_var_key_cache_uint32_t sys_key_cache_division_limit(&vars, "key_cache_division_limit", |
616
by Brian Aker
ulong fixes. |
149 |
offsetof(KEY_CACHE, |
150 |
param_division_limit)); |
|
910.4.18
by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64 |
151 |
static sys_var_key_cache_uint32_t sys_key_cache_age_threshold(&vars, "key_cache_age_threshold", |
616
by Brian Aker
ulong fixes. |
152 |
offsetof(KEY_CACHE, |
153 |
param_age_threshold)); |
|
154 |
static sys_var_session_uint32_t sys_max_allowed_packet(&vars, "max_allowed_packet", |
|
155 |
&SV::max_allowed_packet); |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
156 |
static sys_var_uint64_t_ptr sys_max_connect_errors(&vars, "max_connect_errors", |
616
by Brian Aker
ulong fixes. |
157 |
&max_connect_errors); |
158 |
static sys_var_session_uint64_t sys_max_error_count(&vars, "max_error_count", |
|
159 |
&SV::max_error_count); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
160 |
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size", |
616
by Brian Aker
ulong fixes. |
161 |
&SV::max_heap_table_size); |
555
by Monty
Fixed 32-bit issues. |
162 |
static sys_var_session_uint64_t sys_pseudo_thread_id(&vars, "pseudo_thread_id", |
1
by brian
clean slate |
163 |
&SV::pseudo_thread_id, |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
164 |
0, check_pseudo_thread_id); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
165 |
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size", |
617
by Brian Aker
ulong fixes |
166 |
&SV::max_join_size, |
167 |
fix_max_join_size); |
|
168 |
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 |
169 |
&SV::max_seeks_for_key); |
170 |
static sys_var_session_uint64_t sys_max_length_for_sort_data(&vars, "max_length_for_sort_data", |
|
171 |
&SV::max_length_for_sort_data); |
|
910.4.4
by Stewart Smith
max_sort_length should be size_t everywhere. Causing numerous failures on SPARC and PowerPC due to strang value being retrieved in filesort. Basically, anything with filesort fails without this patch. |
172 |
static sys_var_session_size_t sys_max_sort_length(&vars, "max_sort_length", |
615
by Brian Aker
Added 32bit system variable support |
173 |
&SV::max_sort_length); |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
174 |
static sys_var_uint64_t_ptr sys_max_write_lock_count(&vars, "max_write_lock_count", |
622.1.1
by Brian Aker
32bit fixes around vars |
175 |
&max_write_lock_count); |
619
by Brian Aker
Removed ulong methods from vars. |
176 |
static sys_var_session_uint64_t sys_min_examined_row_limit(&vars, "min_examined_row_limit", |
177 |
&SV::min_examined_row_limit); |
|
1
by brian
clean slate |
178 |
|
179 |
/* these two cannot be static */
|
|
619
by Brian Aker
Removed ulong methods from vars. |
180 |
static sys_var_session_bool sys_optimizer_prune_level(&vars, "optimizer_prune_level", |
181 |
&SV::optimizer_prune_level); |
|
182 |
static sys_var_session_uint32_t sys_optimizer_search_depth(&vars, "optimizer_search_depth", |
|
183 |
&SV::optimizer_search_depth); |
|
1
by brian
clean slate |
184 |
|
619
by Brian Aker
Removed ulong methods from vars. |
185 |
static sys_var_session_uint64_t sys_preload_buff_size(&vars, "preload_buffer_size", |
186 |
&SV::preload_buff_size); |
|
187 |
static sys_var_session_uint32_t sys_read_buff_size(&vars, "read_buffer_size", |
|
188 |
&SV::read_buff_size); |
|
189 |
static sys_var_session_uint32_t sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size", |
|
190 |
&SV::read_rnd_buff_size); |
|
191 |
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment", |
|
192 |
&SV::div_precincrement); |
|
1
by brian
clean slate |
193 |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
194 |
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 |
195 |
&SV::range_alloc_block_size); |
196 |
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size", |
|
197 |
&SV::query_alloc_block_size, |
|
617
by Brian Aker
ulong fixes |
198 |
false, fix_session_mem_root); |
615
by Brian Aker
Added 32bit system variable support |
199 |
static sys_var_session_uint32_t sys_query_prealloc_size(&vars, "query_prealloc_size", |
200 |
&SV::query_prealloc_size, |
|
617
by Brian Aker
ulong fixes |
201 |
false, fix_session_mem_root); |
202 |
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir); |
|
615
by Brian Aker
Added 32bit system variable support |
203 |
static sys_var_session_uint32_t sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size", |
204 |
&SV::trans_alloc_block_size, |
|
617
by Brian Aker
ulong fixes |
205 |
false, fix_trans_mem_root); |
1124.2.7
by Diego Medina
reverted transaction_prealloc_size to an uint32_t |
206 |
static sys_var_session_uint32_t sys_trans_prealloc_size(&vars, "transaction_prealloc_size", |
207 |
&SV::trans_prealloc_size, |
|
208 |
false, fix_session_mem_root); |
|
1
by brian
clean slate |
209 |
|
210 |
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv", |
|
211 |
&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. |
212 |
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id, |
213 |
fix_server_id); |
|
214 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
215 |
static sys_var_session_size_t sys_sort_buffer(&vars, "sort_buffer_size", |
619
by Brian Aker
Removed ulong methods from vars. |
216 |
&SV::sortbuff_size); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
217 |
static sys_var_session_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch", |
617
by Brian Aker
ulong fixes |
218 |
&SV::optimizer_switch); |
1
by brian
clean slate |
219 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
220 |
static sys_var_session_storage_engine sys_storage_engine(&vars, "storage_engine", |
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
221 |
&SV::storage_engine); |
1
by brian
clean slate |
222 |
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone", |
223 |
system_time_zone); |
|
1226.1.3
by Brian Aker
Possible solution for hash/rehash. |
224 |
static sys_var_size_t_ptr sys_table_def_size(&vars, "table_definition_cache", |
225 |
&table_def_size); |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
226 |
static sys_var_uint64_t_ptr sys_table_cache_size(&vars, "table_open_cache", |
1
by brian
clean slate |
227 |
&table_cache_size); |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
228 |
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout", |
1
by brian
clean slate |
229 |
&table_lock_wait_timeout); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
230 |
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation", |
617
by Brian Aker
ulong fixes |
231 |
&SV::tx_isolation, |
232 |
&tx_isolation_typelib, |
|
233 |
fix_tx_isolation, |
|
234 |
check_tx_isolation); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
235 |
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size", |
1
by brian
clean slate |
236 |
&SV::tmp_table_size); |
147
by Brian Aker
More my_bool conversion. This time the set_var class. |
237 |
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes); |
1241.9.12
by Monty Taylor
Trims more out of server_includes.h. |
238 |
static sys_var_const_str sys_version(&vars, "version", drizzled::version().c_str()); |
1228.1.10
by Monty Taylor
Version, length, transaction_log. |
239 |
|
1
by brian
clean slate |
240 |
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) |
241 |
COMPILATION_COMMENT); |
1
by brian
clean slate |
242 |
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine", |
1081.1.1
by Monty Taylor
Whole boat-load of build fixes. |
243 |
HOST_CPU); |
1
by brian
clean slate |
244 |
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os", |
1081.1.1
by Monty Taylor
Whole boat-load of build fixes. |
245 |
HOST_OS); |
246 |
static sys_var_const_str sys_version_compile_vendor(&vars, "version_compile_vendor", |
|
247 |
HOST_VENDOR); |
|
1
by brian
clean slate |
248 |
|
520.1.21
by Brian Aker
THD -> Session rename |
249 |
/* Variables that are bits in Session */
|
1
by brian
clean slate |
250 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
251 |
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0, |
1
by brian
clean slate |
252 |
set_option_autocommit, |
253 |
OPTION_NOT_AUTOCOMMIT, |
|
254 |
1); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
255 |
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0, |
1
by brian
clean slate |
256 |
set_option_bit, |
257 |
OPTION_BIG_SELECTS); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
258 |
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0, |
1
by brian
clean slate |
259 |
set_option_bit, |
260 |
OPTION_WARNINGS); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
261 |
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0, |
1
by brian
clean slate |
262 |
set_option_bit, |
263 |
OPTION_SQL_NOTES); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
264 |
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0, |
1
by brian
clean slate |
265 |
set_option_bit, |
266 |
OPTION_BUFFER_RESULT); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
267 |
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0, |
1
by brian
clean slate |
268 |
set_option_bit, |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
269 |
OPTION_NO_FOREIGN_KEY_CHECKS, 1); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
270 |
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0, |
1
by brian
clean slate |
271 |
set_option_bit, |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
272 |
OPTION_RELAXED_UNIQUE_CHECKS, 1); |
1
by brian
clean slate |
273 |
/* Local state variables */
|
274 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
275 |
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit", |
1
by brian
clean slate |
276 |
&SV::select_limit); |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
277 |
static sys_var_timestamp sys_timestamp(&vars, "timestamp"); |
1
by brian
clean slate |
278 |
static sys_var_last_insert_id |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
279 |
sys_last_insert_id(&vars, "last_insert_id"); |
1
by brian
clean slate |
280 |
/*
|
281 |
identity is an alias for last_insert_id(), so that we are compatible
|
|
282 |
with Sybase
|
|
283 |
*/
|
|
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
284 |
static sys_var_last_insert_id sys_identity(&vars, "identity"); |
1
by brian
clean slate |
285 |
|
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
286 |
static sys_var_session_lc_time_names sys_lc_time_names(&vars, "lc_time_names"); |
1
by brian
clean slate |
287 |
|
288 |
/*
|
|
289 |
We want statements referring explicitly to @@session.insert_id to be
|
|
290 |
unsafe, because insert_id is modified internally by the slave sql
|
|
291 |
thread when NULL values are inserted in an AUTO_INCREMENT column.
|
|
292 |
This modification interfers with the value of the
|
|
293 |
@@session.insert_id variable if @@session.insert_id is referred
|
|
294 |
explicitly by an insert statement (as is seen by executing "SET
|
|
295 |
@@session.insert_id=0; CREATE TABLE t (a INT, b INT KEY
|
|
296 |
AUTO_INCREMENT); INSERT INTO t(a) VALUES (@@session.insert_id);" in
|
|
297 |
statement-based logging mode: t will be different on master and
|
|
298 |
slave).
|
|
299 |
*/
|
|
626
by Brian Aker
More of the same (ulong/64) |
300 |
static sys_var_readonly sys_error_count(&vars, "error_count", |
301 |
OPT_SESSION, |
|
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
302 |
SHOW_INT, |
626
by Brian Aker
More of the same (ulong/64) |
303 |
get_error_count); |
304 |
static sys_var_readonly sys_warning_count(&vars, "warning_count", |
|
305 |
OPT_SESSION, |
|
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
306 |
SHOW_INT, |
626
by Brian Aker
More of the same (ulong/64) |
307 |
get_warning_count); |
1
by brian
clean slate |
308 |
|
617
by Brian Aker
ulong fixes |
309 |
sys_var_session_uint64_t sys_group_concat_max_len(&vars, "group_concat_max_len", |
310 |
&SV::group_concat_max_len); |
|
1
by brian
clean slate |
311 |
|
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
312 |
sys_var_session_time_zone sys_time_zone(&vars, "time_zone"); |
1
by brian
clean slate |
313 |
|
314 |
/* Global read-only variable containing hostname */
|
|
315 |
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname); |
|
316 |
||
317 |
/* Read only variables */
|
|
318 |
||
1241.9.30
by Monty Taylor
More cruft gone. |
319 |
extern SHOW_COMP_OPTION have_symlink; |
1
by brian
clean slate |
320 |
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink); |
321 |
/*
|
|
322 |
Additional variables (not derived from sys_var class, not accessible as
|
|
323 |
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
|
|
324 |
maintenance - SHOW VARIABLES will sort its output.
|
|
325 |
TODO: remove this list completely
|
|
326 |
*/
|
|
327 |
||
328 |
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
|
|
329 |
static SHOW_VAR fixed_vars[]= { |
|
1192.3.43
by Monty Taylor
Removed many, many checks for functions that do not need to be checked. |
330 |
{"back_log", (char*) &back_log, SHOW_INT}, |
331 |
{"language", language, SHOW_CHAR}, |
|
332 |
{"locked_in_memory", (char*) &locked_in_memory, SHOW_MY_BOOL}, |
|
333 |
{"pid_file", (char*) pidfile_name, SHOW_CHAR}, |
|
334 |
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR}, |
|
335 |
{"thread_stack", (char*) &my_thread_stack_size, SHOW_INT}, |
|
1
by brian
clean slate |
336 |
};
|
337 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
338 |
bool sys_var::check(Session *, set_var *var) |
1
by brian
clean slate |
339 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
340 |
var->save_result.uint64_t_value= var->value->val_int(); |
1
by brian
clean slate |
341 |
return 0; |
342 |
}
|
|
343 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
344 |
bool sys_var_str::check(Session *session, set_var *var) |
1
by brian
clean slate |
345 |
{
|
346 |
int res; |
|
347 |
if (!check_func) |
|
348 |
return 0; |
|
349 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
350 |
if ((res=(*check_func)(session, var)) < 0) |
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
351 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr()); |
1
by brian
clean slate |
352 |
return res; |
353 |
}
|
|
354 |
||
355 |
/*
|
|
356 |
Functions to check and update variables
|
|
357 |
*/
|
|
358 |
||
359 |
||
360 |
/**
|
|
361 |
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
|
|
362 |
*/
|
|
363 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
364 |
static void fix_max_join_size(Session *session, enum_var_type type) |
1
by brian
clean slate |
365 |
{
|
366 |
if (type != OPT_GLOBAL) |
|
367 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
368 |
if (session->variables.max_join_size == HA_POS_ERROR) |
369 |
session->options|= OPTION_BIG_SELECTS; |
|
1
by brian
clean slate |
370 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
371 |
session->options&= ~OPTION_BIG_SELECTS; |
1
by brian
clean slate |
372 |
}
|
373 |
}
|
|
374 |
||
375 |
||
376 |
/**
|
|
377 |
Can't change the 'next' tx_isolation while we are already in
|
|
378 |
a transaction
|
|
379 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
380 |
static int check_tx_isolation(Session *session, set_var *var) |
1
by brian
clean slate |
381 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
382 |
if (var->type == OPT_DEFAULT && (session->server_status & SERVER_STATUS_IN_TRANS)) |
1
by brian
clean slate |
383 |
{
|
384 |
my_error(ER_CANT_CHANGE_TX_ISOLATION, MYF(0)); |
|
385 |
return 1; |
|
386 |
}
|
|
387 |
return 0; |
|
388 |
}
|
|
389 |
||
390 |
/*
|
|
391 |
If one doesn't use the SESSION modifier, the isolation level
|
|
392 |
is only active for the next command.
|
|
393 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
394 |
static void fix_tx_isolation(Session *session, enum_var_type type) |
1
by brian
clean slate |
395 |
{
|
396 |
if (type == OPT_SESSION) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
397 |
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. |
398 |
session->variables.tx_isolation); |
1
by brian
clean slate |
399 |
}
|
400 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
401 |
static void fix_completion_type(Session *, enum_var_type) {} |
1
by brian
clean slate |
402 |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
403 |
static int check_completion_type(Session *, set_var *var) |
1
by brian
clean slate |
404 |
{
|
152
by Brian Aker
longlong replacement |
405 |
int64_t val= var->value->val_int(); |
1
by brian
clean slate |
406 |
if (val < 0 || val > 2) |
407 |
{
|
|
408 |
char buf[64]; |
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
409 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->getName().c_str(), llstr(val, buf)); |
1
by brian
clean slate |
410 |
return 1; |
411 |
}
|
|
412 |
return 0; |
|
413 |
}
|
|
414 |
||
415 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
416 |
static void fix_session_mem_root(Session *session, enum_var_type type) |
417 |
{
|
|
418 |
if (type != OPT_GLOBAL) |
|
419 |
reset_root_defaults(session->mem_root, |
|
420 |
session->variables.query_alloc_block_size, |
|
421 |
session->variables.query_prealloc_size); |
|
422 |
}
|
|
423 |
||
424 |
||
425 |
static void fix_trans_mem_root(Session *session, enum_var_type type) |
|
426 |
{
|
|
427 |
if (type != OPT_GLOBAL) |
|
428 |
reset_root_defaults(&session->transaction.mem_root, |
|
429 |
session->variables.trans_alloc_block_size, |
|
430 |
session->variables.trans_prealloc_size); |
|
431 |
}
|
|
432 |
||
433 |
||
988.1.3
by Jay Pipes
Fixed up the removal of Session::server_id |
434 |
static void fix_server_id(Session *, enum_var_type) |
1
by brian
clean slate |
435 |
{
|
436 |
}
|
|
437 |
||
438 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
439 |
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
440 |
const std::string &name, int64_t val) |
1
by brian
clean slate |
441 |
{
|
442 |
if (fixed) |
|
443 |
{
|
|
444 |
char buf[22]; |
|
445 |
||
446 |
if (unsignd) |
|
151
by Brian Aker
Ulonglong to uint64_t |
447 |
ullstr((uint64_t) val, buf); |
1
by brian
clean slate |
448 |
else
|
449 |
llstr(val, buf); |
|
450 |
||
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
451 |
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, |
1
by brian
clean slate |
452 |
ER_TRUNCATED_WRONG_VALUE, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
453 |
ER(ER_TRUNCATED_WRONG_VALUE), name.c_str(), buf); |
1
by brian
clean slate |
454 |
}
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
455 |
return false; |
1
by brian
clean slate |
456 |
}
|
457 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
458 |
static uint64_t fix_unsigned(Session *session, uint64_t num, |
1
by brian
clean slate |
459 |
const struct my_option *option_limits) |
460 |
{
|
|
143
by Brian Aker
Bool cleanup. |
461 |
bool fixed= false; |
151
by Brian Aker
Ulonglong to uint64_t |
462 |
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed); |
1
by brian
clean slate |
463 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
464 |
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num); |
1
by brian
clean slate |
465 |
return out; |
466 |
}
|
|
467 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
468 |
|
469 |
static size_t fix_size_t(Session *session, size_t num, |
|
470 |
const struct my_option *option_limits) |
|
471 |
{
|
|
472 |
bool fixed= false; |
|
473 |
size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed); |
|
474 |
||
475 |
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num); |
|
476 |
return out; |
|
477 |
}
|
|
478 |
||
1124.2.7
by Diego Medina
reverted transaction_prealloc_size to an uint32_t |
479 |
static bool get_unsigned32(Session *session, set_var *var) |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
480 |
{
|
481 |
if (var->value->unsigned_flag) |
|
1124.2.7
by Diego Medina
reverted transaction_prealloc_size to an uint32_t |
482 |
var->save_result.uint32_t_value= |
483 |
static_cast<uint32_t>(var->value->val_int()); |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
484 |
else
|
485 |
{
|
|
486 |
int64_t v= var->value->val_int(); |
|
1124.2.7
by Diego Medina
reverted transaction_prealloc_size to an uint32_t |
487 |
if (v > UINT32_MAX) |
488 |
throw_bounds_warning(session, true, true,var->var->getName().c_str(), v); |
|
489 |
||
490 |
var->save_result.uint32_t_value= |
|
491 |
static_cast<uint32_t>((v > UINT32_MAX) ? UINT32_MAX : (v < 0) ? 0 : v); |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
492 |
}
|
1124.2.7
by Diego Medina
reverted transaction_prealloc_size to an uint32_t |
493 |
return false; |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
494 |
}
|
495 |
||
496 |
static bool get_unsigned64(Session *, set_var *var) |
|
497 |
{
|
|
498 |
if (var->value->unsigned_flag) |
|
499 |
var->save_result.uint64_t_value=(uint64_t) var->value->val_int(); |
|
500 |
else
|
|
501 |
{
|
|
502 |
int64_t v= var->value->val_int(); |
|
503 |
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v); |
|
1
by brian
clean slate |
504 |
}
|
505 |
return 0; |
|
506 |
}
|
|
507 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
508 |
static bool get_size_t(Session *, set_var *var) |
509 |
{
|
|
510 |
if (var->value->unsigned_flag) |
|
910.4.9
by Stewart Smith
fix size_t variables on platforms where sizeof(size_t)=4 |
511 |
var->save_result.size_t_value= (size_t) var->value->val_int(); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
512 |
else
|
513 |
{
|
|
892.2.2
by Monty Taylor
More solaris warnings. |
514 |
ssize_t v= (ssize_t)var->value->val_int(); |
910.4.9
by Stewart Smith
fix size_t variables on platforms where sizeof(size_t)=4 |
515 |
var->save_result.size_t_value= (size_t) ((v < 0) ? 0 : v); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
516 |
}
|
517 |
return 0; |
|
518 |
}
|
|
519 |
||
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
520 |
bool sys_var_uint32_t_ptr::check(Session *, set_var *var) |
521 |
{
|
|
988.2.2
by Trond Norbye
size_t and uint64_t is not the same in 32 bit builds. Add explicit casting |
522 |
var->save_result.uint32_t_value= (uint32_t)var->value->val_int(); |
1
by brian
clean slate |
523 |
return 0; |
524 |
}
|
|
525 |
||
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. |
526 |
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var) |
527 |
{
|
|
528 |
uint32_t tmp= var->save_result.uint32_t_value; |
|
529 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
530 |
if (option_limits) |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
531 |
{
|
532 |
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits); |
|
533 |
if(newvalue==tmp) |
|
534 |
*value= newvalue; |
|
535 |
}
|
|
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. |
536 |
else
|
537 |
*value= (uint32_t) tmp; |
|
538 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
539 |
return 0; |
|
540 |
}
|
|
541 |
||
542 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
543 |
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. |
544 |
{
|
545 |
bool not_used; |
|
546 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
892.2.2
by Monty Taylor
More solaris warnings. |
547 |
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value, |
548 |
option_limits, ¬_used); |
|
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. |
549 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
550 |
}
|
|
551 |
||
1
by brian
clean slate |
552 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
553 |
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var) |
1
by brian
clean slate |
554 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
555 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
556 |
pthread_mutex_lock(&LOCK_global_system_variables); |
557 |
if (option_limits) |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
558 |
{
|
559 |
uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits); |
|
560 |
if(newvalue==tmp) |
|
561 |
*value= newvalue; |
|
562 |
}
|
|
1
by brian
clean slate |
563 |
else
|
151
by Brian Aker
Ulonglong to uint64_t |
564 |
*value= (uint64_t) tmp; |
1
by brian
clean slate |
565 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
566 |
return 0; |
|
567 |
}
|
|
568 |
||
569 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
570 |
void sys_var_uint64_t_ptr::set_default(Session *, enum_var_type) |
1
by brian
clean slate |
571 |
{
|
143
by Brian Aker
Bool cleanup. |
572 |
bool not_used; |
1
by brian
clean slate |
573 |
pthread_mutex_lock(&LOCK_global_system_variables); |
151
by Brian Aker
Ulonglong to uint64_t |
574 |
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value, |
1
by brian
clean slate |
575 |
option_limits, ¬_used); |
576 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
577 |
}
|
|
578 |
||
579 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
580 |
bool sys_var_size_t_ptr::update(Session *session, set_var *var) |
581 |
{
|
|
582 |
size_t tmp= var->save_result.size_t_value; |
|
583 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
584 |
if (option_limits) |
|
585 |
*value= fix_size_t(session, tmp, option_limits); |
|
586 |
else
|
|
587 |
*value= tmp; |
|
588 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
589 |
return 0; |
|
590 |
}
|
|
591 |
||
592 |
||
593 |
void sys_var_size_t_ptr::set_default(Session *, enum_var_type) |
|
594 |
{
|
|
595 |
bool not_used; |
|
596 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
597 |
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value, |
|
598 |
option_limits, ¬_used); |
|
599 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
600 |
}
|
|
601 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
602 |
bool sys_var_bool_ptr::update(Session *, set_var *var) |
1
by brian
clean slate |
603 |
{
|
576
by Brian Aker
ulong conversion work |
604 |
*value= (bool) var->save_result.uint32_t_value; |
1
by brian
clean slate |
605 |
return 0; |
606 |
}
|
|
607 |
||
608 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
609 |
void sys_var_bool_ptr::set_default(Session *, enum_var_type) |
1
by brian
clean slate |
610 |
{
|
146
by Brian Aker
my_bool cleanup. |
611 |
*value= (bool) option_limits->def_value; |
612 |
}
|
|
613 |
||
1
by brian
clean slate |
614 |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
615 |
bool sys_var_enum::update(Session *, set_var *var) |
1
by brian
clean slate |
616 |
{
|
895
by Brian Aker
Completion (?) of uint conversion. |
617 |
*value= (uint32_t) var->save_result.uint32_t_value; |
1
by brian
clean slate |
618 |
return 0; |
619 |
}
|
|
620 |
||
621 |
||
779.3.10
by Monty Taylor
Turned on -Wshadow. |
622 |
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, const LEX_STRING *) |
1
by brian
clean slate |
623 |
{
|
481
by Brian Aker
Remove all of uchar. |
624 |
return (unsigned char*) enum_names->type_names[*value]; |
1
by brian
clean slate |
625 |
}
|
626 |
||
627 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
628 |
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
629 |
const LEX_STRING *) |
1
by brian
clean slate |
630 |
{
|
481
by Brian Aker
Remove all of uchar. |
631 |
return (unsigned char*) enum_names->type_names[global_system_variables.*offset]; |
1
by brian
clean slate |
632 |
}
|
633 |
||
615
by Brian Aker
Added 32bit system variable support |
634 |
/*
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
635 |
32 bit types for session variables
|
615
by Brian Aker
Added 32bit system variable support |
636 |
*/
|
637 |
bool sys_var_session_uint32_t::check(Session *session, set_var *var) |
|
638 |
{
|
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
639 |
return (get_unsigned32(session, var) || |
615
by Brian Aker
Added 32bit system variable support |
640 |
(check_func && (*check_func)(session, var))); |
641 |
}
|
|
642 |
||
643 |
bool sys_var_session_uint32_t::update(Session *session, set_var *var) |
|
644 |
{
|
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
645 |
uint64_t tmp= (uint64_t) var->save_result.uint32_t_value; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
646 |
|
615
by Brian Aker
Added 32bit system variable support |
647 |
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
648 |
if ((uint32_t) tmp > max_system_variables.*offset) |
|
649 |
{
|
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
650 |
throw_bounds_warning(session, true, true, getName(), (int64_t) tmp); |
615
by Brian Aker
Added 32bit system variable support |
651 |
tmp= max_system_variables.*offset; |
652 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
653 |
|
615
by Brian Aker
Added 32bit system variable support |
654 |
if (option_limits) |
655 |
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits); |
|
656 |
else if (tmp > UINT32_MAX) |
|
657 |
{
|
|
658 |
tmp= UINT32_MAX; |
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
659 |
throw_bounds_warning(session, true, true, getName(), (int64_t) var->save_result.uint64_t_value); |
615
by Brian Aker
Added 32bit system variable support |
660 |
}
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
661 |
|
615
by Brian Aker
Added 32bit system variable support |
662 |
if (var->type == OPT_GLOBAL) |
663 |
global_system_variables.*offset= (uint32_t) tmp; |
|
664 |
else
|
|
665 |
session->variables.*offset= (uint32_t) tmp; |
|
666 |
||
667 |
return 0; |
|
668 |
}
|
|
669 |
||
670 |
||
671 |
void sys_var_session_uint32_t::set_default(Session *session, enum_var_type type) |
|
672 |
{
|
|
673 |
if (type == OPT_GLOBAL) |
|
674 |
{
|
|
675 |
bool not_used; |
|
676 |
/* We will not come here if option_limits is not set */
|
|
677 |
global_system_variables.*offset= |
|
678 |
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value, |
|
679 |
option_limits, ¬_used); |
|
680 |
}
|
|
681 |
else
|
|
682 |
session->variables.*offset= global_system_variables.*offset; |
|
683 |
}
|
|
684 |
||
685 |
||
686 |
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session, |
|
687 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
688 |
const LEX_STRING *) |
615
by Brian Aker
Added 32bit system variable support |
689 |
{
|
690 |
if (type == OPT_GLOBAL) |
|
691 |
return (unsigned char*) &(global_system_variables.*offset); |
|
692 |
return (unsigned char*) &(session->variables.*offset); |
|
693 |
}
|
|
694 |
||
1
by brian
clean slate |
695 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
696 |
bool sys_var_session_ha_rows::update(Session *session, set_var *var) |
1
by brian
clean slate |
697 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
698 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
699 |
|
700 |
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
|
701 |
if ((ha_rows) tmp > max_system_variables.*offset) |
|
702 |
tmp= max_system_variables.*offset; |
|
703 |
||
704 |
if (option_limits) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
705 |
tmp= (ha_rows) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
706 |
if (var->type == OPT_GLOBAL) |
707 |
{
|
|
708 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
709 |
pthread_mutex_lock(&LOCK_global_system_variables); |
1
by brian
clean slate |
710 |
global_system_variables.*offset= (ha_rows) tmp; |
711 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
712 |
}
|
|
713 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
714 |
session->variables.*offset= (ha_rows) tmp; |
1
by brian
clean slate |
715 |
return 0; |
716 |
}
|
|
717 |
||
718 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
719 |
void sys_var_session_ha_rows::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
720 |
{
|
721 |
if (type == OPT_GLOBAL) |
|
722 |
{
|
|
143
by Brian Aker
Bool cleanup. |
723 |
bool not_used; |
1
by brian
clean slate |
724 |
/* We will not come here if option_limits is not set */
|
725 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
726 |
global_system_variables.*offset= |
|
727 |
(ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value, |
|
728 |
option_limits, ¬_used); |
|
729 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
730 |
}
|
|
731 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
732 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
733 |
}
|
734 |
||
735 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
736 |
unsigned char *sys_var_session_ha_rows::value_ptr(Session *session, |
737 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
738 |
const LEX_STRING *) |
1
by brian
clean slate |
739 |
{
|
740 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
741 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
742 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
743 |
}
|
744 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
745 |
bool sys_var_session_uint64_t::check(Session *session, set_var *var) |
1
by brian
clean slate |
746 |
{
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
747 |
return (get_unsigned64(session, var) || |
555
by Monty
Fixed 32-bit issues. |
748 |
(check_func && (*check_func)(session, var))); |
1
by brian
clean slate |
749 |
}
|
750 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
751 |
bool sys_var_session_uint64_t::update(Session *session, set_var *var) |
1
by brian
clean slate |
752 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
753 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
754 |
|
755 |
if (tmp > max_system_variables.*offset) |
|
1124.2.2
by Diego Medina
Added missing { } for if statement |
756 |
{
|
757 |
throw_bounds_warning(session, true, true, getName(), (int64_t) tmp); |
|
1
by brian
clean slate |
758 |
tmp= max_system_variables.*offset; |
1124.2.2
by Diego Medina
Added missing { } for if statement |
759 |
}
|
1
by brian
clean slate |
760 |
|
761 |
if (option_limits) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
762 |
tmp= fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
763 |
if (var->type == OPT_GLOBAL) |
764 |
{
|
|
765 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
766 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
151
by Brian Aker
Ulonglong to uint64_t |
767 |
global_system_variables.*offset= (uint64_t) tmp; |
1
by brian
clean slate |
768 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
769 |
}
|
|
770 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
771 |
session->variables.*offset= (uint64_t) tmp; |
1
by brian
clean slate |
772 |
return 0; |
773 |
}
|
|
774 |
||
775 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
776 |
void sys_var_session_uint64_t::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
777 |
{
|
778 |
if (type == OPT_GLOBAL) |
|
779 |
{
|
|
143
by Brian Aker
Bool cleanup. |
780 |
bool not_used; |
1
by brian
clean slate |
781 |
pthread_mutex_lock(&LOCK_global_system_variables); |
782 |
global_system_variables.*offset= |
|
151
by Brian Aker
Ulonglong to uint64_t |
783 |
getopt_ull_limit_value((uint64_t) option_limits->def_value, |
1
by brian
clean slate |
784 |
option_limits, ¬_used); |
785 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
786 |
}
|
|
787 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
788 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
789 |
}
|
790 |
||
791 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
792 |
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session, |
793 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
794 |
const LEX_STRING *) |
1
by brian
clean slate |
795 |
{
|
796 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
797 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
798 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
799 |
}
|
800 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
801 |
bool sys_var_session_size_t::check(Session *session, set_var *var) |
802 |
{
|
|
803 |
return (get_size_t(session, var) || |
|
804 |
(check_func && (*check_func)(session, var))); |
|
805 |
}
|
|
806 |
||
807 |
bool sys_var_session_size_t::update(Session *session, set_var *var) |
|
808 |
{
|
|
809 |
size_t tmp= var->save_result.size_t_value; |
|
810 |
||
811 |
if (tmp > max_system_variables.*offset) |
|
812 |
tmp= max_system_variables.*offset; |
|
813 |
||
814 |
if (option_limits) |
|
815 |
tmp= fix_size_t(session, tmp, option_limits); |
|
816 |
if (var->type == OPT_GLOBAL) |
|
817 |
{
|
|
818 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
819 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
820 |
global_system_variables.*offset= tmp; |
|
821 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
822 |
}
|
|
823 |
else
|
|
824 |
session->variables.*offset= tmp; |
|
825 |
return 0; |
|
826 |
}
|
|
827 |
||
828 |
||
829 |
void sys_var_session_size_t::set_default(Session *session, enum_var_type type) |
|
830 |
{
|
|
831 |
if (type == OPT_GLOBAL) |
|
832 |
{
|
|
833 |
bool not_used; |
|
834 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
835 |
global_system_variables.*offset= |
|
892.2.2
by Monty Taylor
More solaris warnings. |
836 |
(size_t)getopt_ull_limit_value((size_t) option_limits->def_value, |
837 |
option_limits, ¬_used); |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
838 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
839 |
}
|
|
840 |
else
|
|
841 |
session->variables.*offset= global_system_variables.*offset; |
|
842 |
}
|
|
843 |
||
844 |
||
845 |
unsigned char *sys_var_session_size_t::value_ptr(Session *session, |
|
846 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
847 |
const LEX_STRING *) |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
848 |
{
|
849 |
if (type == OPT_GLOBAL) |
|
850 |
return (unsigned char*) &(global_system_variables.*offset); |
|
851 |
return (unsigned char*) &(session->variables.*offset); |
|
852 |
}
|
|
853 |
||
1
by brian
clean slate |
854 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
855 |
bool sys_var_session_bool::update(Session *session, set_var *var) |
1
by brian
clean slate |
856 |
{
|
857 |
if (var->type == OPT_GLOBAL) |
|
576
by Brian Aker
ulong conversion work |
858 |
global_system_variables.*offset= (bool) var->save_result.uint32_t_value; |
1
by brian
clean slate |
859 |
else
|
576
by Brian Aker
ulong conversion work |
860 |
session->variables.*offset= (bool) var->save_result.uint32_t_value; |
1
by brian
clean slate |
861 |
return 0; |
862 |
}
|
|
863 |
||
864 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
865 |
void sys_var_session_bool::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
866 |
{
|
867 |
if (type == OPT_GLOBAL) |
|
200
by Brian Aker
my_bool from handler and set_var |
868 |
global_system_variables.*offset= (bool) option_limits->def_value; |
1
by brian
clean slate |
869 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
870 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
871 |
}
|
872 |
||
873 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
874 |
unsigned char *sys_var_session_bool::value_ptr(Session *session, |
875 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
876 |
const LEX_STRING *) |
1
by brian
clean slate |
877 |
{
|
878 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
879 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
880 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
881 |
}
|
882 |
||
883 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
884 |
bool sys_var::check_enum(Session *, |
77.1.45
by Monty Taylor
Warning fixes. |
885 |
set_var *var, const TYPELIB *enum_names) |
1
by brian
clean slate |
886 |
{
|
887 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
888 |
const char *value; |
|
889 |
String str(buff, sizeof(buff), system_charset_info), *res; |
|
890 |
||
891 |
if (var->value->result_type() == STRING_RESULT) |
|
892 |
{
|
|
971.2.1
by Eric Day
Fix for bug #311025. This was due to code that was removed during ulong cleanup (r576). |
893 |
if (!(res=var->value->val_str(&str)) || |
894 |
(var->save_result.uint32_t_value= find_type(enum_names, res->ptr(), |
|
895 |
res->length(),1)) == 0) |
|
1
by brian
clean slate |
896 |
{
|
897 |
value= res ? res->c_ptr() : "NULL"; |
|
898 |
goto err; |
|
899 |
}
|
|
971.2.1
by Eric Day
Fix for bug #311025. This was due to code that was removed during ulong cleanup (r576). |
900 |
|
901 |
var->save_result.uint32_t_value--; |
|
1
by brian
clean slate |
902 |
}
|
903 |
else
|
|
904 |
{
|
|
151
by Brian Aker
Ulonglong to uint64_t |
905 |
uint64_t tmp=var->value->val_int(); |
1
by brian
clean slate |
906 |
if (tmp >= enum_names->count) |
907 |
{
|
|
908 |
llstr(tmp,buff); |
|
909 |
value=buff; // Wrong value is here |
|
910 |
goto err; |
|
911 |
}
|
|
576
by Brian Aker
ulong conversion work |
912 |
var->save_result.uint32_t_value= (uint32_t) tmp; // Save for update |
1
by brian
clean slate |
913 |
}
|
914 |
return 0; |
|
915 |
||
916 |
err: |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
917 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.c_str(), value); |
1
by brian
clean slate |
918 |
return 1; |
919 |
}
|
|
920 |
||
921 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
922 |
bool sys_var::check_set(Session *, set_var *var, TYPELIB *enum_names) |
1
by brian
clean slate |
923 |
{
|
924 |
bool not_used; |
|
925 |
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0; |
|
482
by Brian Aker
Remove uint. |
926 |
uint32_t error_len= 0; |
1
by brian
clean slate |
927 |
String str(buff, sizeof(buff), system_charset_info), *res; |
928 |
||
929 |
if (var->value->result_type() == STRING_RESULT) |
|
930 |
{
|
|
931 |
if (!(res= var->value->val_str(&str))) |
|
932 |
{
|
|
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
933 |
strcpy(buff, "NULL"); |
1
by brian
clean slate |
934 |
goto err; |
935 |
}
|
|
936 |
||
1055.2.19
by Jay Pipes
Removes dead set_empty_value_allowed() method of set_var |
937 |
if (! m_allow_empty_value && res->length() == 0) |
1
by brian
clean slate |
938 |
{
|
939 |
buff[0]= 0; |
|
940 |
goto err; |
|
941 |
}
|
|
942 |
||
576
by Brian Aker
ulong conversion work |
943 |
var->save_result.uint32_t_value= ((uint32_t) |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
944 |
find_set(enum_names, res->c_ptr(), |
945 |
res->length(), |
|
946 |
NULL, |
|
947 |
&error, &error_len, |
|
948 |
¬_used)); |
|
1
by brian
clean slate |
949 |
if (error_len) |
950 |
{
|
|
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
951 |
size_t len = min((uint32_t)(sizeof(buff) - 1), error_len); |
629.5.3
by Toru Maesaka
Third pass of replacing MySQL's strmake() with libc calls |
952 |
strncpy(buff, error, len); |
953 |
buff[len]= '\0'; |
|
1
by brian
clean slate |
954 |
goto err; |
955 |
}
|
|
956 |
}
|
|
957 |
else
|
|
958 |
{
|
|
151
by Brian Aker
Ulonglong to uint64_t |
959 |
uint64_t tmp= var->value->val_int(); |
1
by brian
clean slate |
960 |
|
1055.2.19
by Jay Pipes
Removes dead set_empty_value_allowed() method of set_var |
961 |
if (! m_allow_empty_value && tmp == 0) |
1
by brian
clean slate |
962 |
{
|
963 |
buff[0]= '0'; |
|
964 |
buff[1]= 0; |
|
965 |
goto err; |
|
966 |
}
|
|
967 |
||
968 |
/*
|
|
969 |
For when the enum is made to contain 64 elements, as 1ULL<<64 is
|
|
970 |
undefined, we guard with a "count<64" test.
|
|
971 |
*/
|
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
972 |
if (unlikely((tmp >= ((1UL) << enum_names->count)) && |
1
by brian
clean slate |
973 |
(enum_names->count < 64))) |
974 |
{
|
|
975 |
llstr(tmp, buff); |
|
976 |
goto err; |
|
977 |
}
|
|
576
by Brian Aker
ulong conversion work |
978 |
var->save_result.uint32_t_value= (uint32_t) tmp; // Save for update |
1
by brian
clean slate |
979 |
}
|
980 |
return 0; |
|
981 |
||
982 |
err: |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
983 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.c_str(), buff); |
1
by brian
clean slate |
984 |
return 1; |
985 |
}
|
|
986 |
||
987 |
||
988 |
/**
|
|
989 |
Return an Item for a variable.
|
|
990 |
||
991 |
Used with @@[global.]variable_name.
|
|
992 |
||
993 |
If type is not given, return local value if exists, else global.
|
|
994 |
*/
|
|
995 |
||
779.3.10
by Monty Taylor
Turned on -Wshadow. |
996 |
Item *sys_var::item(Session *session, enum_var_type var_type, const LEX_STRING *base) |
1
by brian
clean slate |
997 |
{
|
998 |
if (check_type(var_type)) |
|
999 |
{
|
|
1000 |
if (var_type != OPT_DEFAULT) |
|
1001 |
{
|
|
1002 |
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
1003 |
name.c_str(), var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); |
1
by brian
clean slate |
1004 |
return 0; |
1005 |
}
|
|
1006 |
/* As there was no local variable, return the global value */
|
|
1007 |
var_type= OPT_GLOBAL; |
|
1008 |
}
|
|
1009 |
switch (show_type()) { |
|
625
by Brian Aker
ulong/64 bit straighten out. |
1010 |
case SHOW_LONG: |
1
by brian
clean slate |
1011 |
case SHOW_INT: |
1012 |
{
|
|
482
by Brian Aker
Remove uint. |
1013 |
uint32_t value; |
1
by brian
clean slate |
1014 |
pthread_mutex_lock(&LOCK_global_system_variables); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1015 |
value= *(uint*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1016 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
151
by Brian Aker
Ulonglong to uint64_t |
1017 |
return new Item_uint((uint64_t) value); |
1
by brian
clean slate |
1018 |
}
|
1019 |
case SHOW_LONGLONG: |
|
1020 |
{
|
|
152
by Brian Aker
longlong replacement |
1021 |
int64_t value; |
1
by brian
clean slate |
1022 |
pthread_mutex_lock(&LOCK_global_system_variables); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1023 |
value= *(int64_t*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1024 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1025 |
return new Item_int(value); |
|
1026 |
}
|
|
1027 |
case SHOW_DOUBLE: |
|
1028 |
{
|
|
1029 |
double value; |
|
1030 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1031 |
value= *(double*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1032 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1033 |
/* 6, as this is for now only used with microseconds */
|
|
1034 |
return new Item_float(value, 6); |
|
1035 |
}
|
|
1036 |
case SHOW_HA_ROWS: |
|
1037 |
{
|
|
1038 |
ha_rows value; |
|
1039 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1040 |
value= *(ha_rows*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1041 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
151
by Brian Aker
Ulonglong to uint64_t |
1042 |
return new Item_int((uint64_t) value); |
1
by brian
clean slate |
1043 |
}
|
673.3.17
by Stewart Smith
mostly fix repair test. fix syntax for Drizzle (all tests are MyISAM reliant). |
1044 |
case SHOW_SIZE: |
1045 |
{
|
|
1046 |
size_t value; |
|
1047 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1048 |
value= *(size_t*) value_ptr(session, var_type, base); |
|
1049 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1050 |
return new Item_int((uint64_t) value); |
|
1051 |
}
|
|
1
by brian
clean slate |
1052 |
case SHOW_MY_BOOL: |
1053 |
{
|
|
205
by Brian Aker
uint32 -> uin32_t |
1054 |
int32_t value; |
1
by brian
clean slate |
1055 |
pthread_mutex_lock(&LOCK_global_system_variables); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1056 |
value= *(bool*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1057 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1058 |
return new Item_int(value,1); |
|
1059 |
}
|
|
1060 |
case SHOW_CHAR_PTR: |
|
1061 |
{
|
|
1062 |
Item *tmp; |
|
1063 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1064 |
char *str= *(char**) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1065 |
if (str) |
1066 |
{
|
|
482
by Brian Aker
Remove uint. |
1067 |
uint32_t length= strlen(str); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1068 |
tmp= new Item_string(session->strmake(str, length), length, |
1
by brian
clean slate |
1069 |
system_charset_info, DERIVATION_SYSCONST); |
1070 |
}
|
|
1071 |
else
|
|
1072 |
{
|
|
1073 |
tmp= new Item_null(); |
|
1074 |
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); |
|
1075 |
}
|
|
1076 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1077 |
return tmp; |
|
1078 |
}
|
|
1079 |
case SHOW_CHAR: |
|
1080 |
{
|
|
1081 |
Item *tmp; |
|
1082 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1083 |
char *str= (char*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
1084 |
if (str) |
1085 |
tmp= new Item_string(str, strlen(str), |
|
1086 |
system_charset_info, DERIVATION_SYSCONST); |
|
1087 |
else
|
|
1088 |
{
|
|
1089 |
tmp= new Item_null(); |
|
1090 |
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); |
|
1091 |
}
|
|
1092 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1093 |
return tmp; |
|
1094 |
}
|
|
1095 |
default: |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
1096 |
my_error(ER_VAR_CANT_BE_READ, MYF(0), name.c_str()); |
1
by brian
clean slate |
1097 |
}
|
1098 |
return 0; |
|
1099 |
}
|
|
1100 |
||
1101 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1102 |
bool sys_var_session_enum::update(Session *session, set_var *var) |
1
by brian
clean slate |
1103 |
{
|
1104 |
if (var->type == OPT_GLOBAL) |
|
576
by Brian Aker
ulong conversion work |
1105 |
global_system_variables.*offset= var->save_result.uint32_t_value; |
1
by brian
clean slate |
1106 |
else
|
576
by Brian Aker
ulong conversion work |
1107 |
session->variables.*offset= var->save_result.uint32_t_value; |
1
by brian
clean slate |
1108 |
return 0; |
1109 |
}
|
|
1110 |
||
1111 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1112 |
void sys_var_session_enum::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1113 |
{
|
1114 |
if (type == OPT_GLOBAL) |
|
621
by Brian Aker
ulong fixes |
1115 |
global_system_variables.*offset= (uint32_t) option_limits->def_value; |
1
by brian
clean slate |
1116 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1117 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1118 |
}
|
1119 |
||
1120 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1121 |
unsigned char *sys_var_session_enum::value_ptr(Session *session, |
1122 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1123 |
const LEX_STRING *) |
1
by brian
clean slate |
1124 |
{
|
621
by Brian Aker
ulong fixes |
1125 |
uint32_t tmp= ((type == OPT_GLOBAL) ? |
1
by brian
clean slate |
1126 |
global_system_variables.*offset : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1127 |
session->variables.*offset); |
481
by Brian Aker
Remove all of uchar. |
1128 |
return (unsigned char*) enum_names->type_names[tmp]; |
1
by brian
clean slate |
1129 |
}
|
1130 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1131 |
bool sys_var_session_bit::check(Session *session, set_var *var) |
1
by brian
clean slate |
1132 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1133 |
return (check_enum(session, var, &bool_typelib) || |
1134 |
(check_func && (*check_func)(session, var))); |
|
1
by brian
clean slate |
1135 |
}
|
1136 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1137 |
bool sys_var_session_bit::update(Session *session, set_var *var) |
1
by brian
clean slate |
1138 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1139 |
int res= (*update_func)(session, var); |
1
by brian
clean slate |
1140 |
return res; |
1141 |
}
|
|
1142 |
||
1143 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1144 |
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1145 |
const LEX_STRING *) |
1
by brian
clean slate |
1146 |
{
|
1147 |
/*
|
|
1148 |
If reverse is 0 (default) return 1 if bit is set.
|
|
1149 |
If reverse is 1, return 0 if bit is set
|
|
1150 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1151 |
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ? |
1
by brian
clean slate |
1152 |
!reverse : reverse); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1153 |
return (unsigned char*) &session->sys_var_tmp.bool_value; |
1
by brian
clean slate |
1154 |
}
|
1155 |
||
1156 |
||
1157 |
typedef struct old_names_map_st |
|
1158 |
{
|
|
1159 |
const char *old_name; |
|
1160 |
const char *new_name; |
|
1161 |
} my_old_conv; |
|
1162 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1163 |
bool sys_var_collation::check(Session *, set_var *var) |
1
by brian
clean slate |
1164 |
{
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1165 |
const CHARSET_INFO *tmp; |
1
by brian
clean slate |
1166 |
|
1167 |
if (var->value->result_type() == STRING_RESULT) |
|
1168 |
{
|
|
1169 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
1170 |
String str(buff,sizeof(buff), system_charset_info), *res; |
|
1171 |
if (!(res=var->value->val_str(&str))) |
|
1172 |
{
|
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
1173 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.c_str(), "NULL"); |
1
by brian
clean slate |
1174 |
return 1; |
1175 |
}
|
|
862
by Brian Aker
Remove charset directory code. |
1176 |
if (!(tmp=get_charset_by_name(res->c_ptr()))) |
1
by brian
clean slate |
1177 |
{
|
1178 |
my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr()); |
|
1179 |
return 1; |
|
1180 |
}
|
|
1181 |
}
|
|
1182 |
else // INT_RESULT |
|
1183 |
{
|
|
862
by Brian Aker
Remove charset directory code. |
1184 |
if (!(tmp=get_charset((int) var->value->val_int()))) |
1
by brian
clean slate |
1185 |
{
|
1186 |
char buf[20]; |
|
1187 |
int10_to_str((int) var->value->val_int(), buf, -10); |
|
1188 |
my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); |
|
1189 |
return 1; |
|
1190 |
}
|
|
1191 |
}
|
|
1192 |
var->save_result.charset= tmp; // Save for update |
|
1193 |
return 0; |
|
1194 |
}
|
|
1195 |
||
1196 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1197 |
bool sys_var_collation_sv::update(Session *session, set_var *var) |
1
by brian
clean slate |
1198 |
{
|
1199 |
if (var->type == OPT_GLOBAL) |
|
1200 |
global_system_variables.*offset= var->save_result.charset; |
|
1201 |
else
|
|
1202 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1203 |
session->variables.*offset= var->save_result.charset; |
1
by brian
clean slate |
1204 |
}
|
1205 |
return 0; |
|
1206 |
}
|
|
1207 |
||
1208 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1209 |
void sys_var_collation_sv::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1210 |
{
|
1211 |
if (type == OPT_GLOBAL) |
|
1212 |
global_system_variables.*offset= *global_default; |
|
1213 |
else
|
|
1214 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1215 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1216 |
}
|
1217 |
}
|
|
1218 |
||
1219 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1220 |
unsigned char *sys_var_collation_sv::value_ptr(Session *session, |
1221 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1222 |
const LEX_STRING *) |
1
by brian
clean slate |
1223 |
{
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1224 |
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. |
1225 |
global_system_variables.*offset : |
1226 |
session->variables.*offset); |
|
481
by Brian Aker
Remove all of uchar. |
1227 |
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL"; |
1
by brian
clean slate |
1228 |
}
|
1229 |
||
1230 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1231 |
unsigned char *sys_var_key_cache_param::value_ptr(Session *, enum_var_type, |
1106.4.2
by Brian Aker
Remove multi key cache |
1232 |
const LEX_STRING *) |
1233 |
{
|
|
1234 |
return (unsigned char*) dflt_key_cache + offset ; |
|
1235 |
}
|
|
1236 |
||
1237 |
/**
|
|
1238 |
Resize key cache.
|
|
1239 |
*/
|
|
1240 |
static int resize_key_cache_with_lock(KEY_CACHE *key_cache) |
|
1241 |
{
|
|
1242 |
assert(key_cache->key_cache_inited); |
|
1243 |
||
1244 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1245 |
long tmp_buff_size= (long) key_cache->param_buff_size; |
|
1246 |
long tmp_block_size= (long) key_cache->param_block_size; |
|
1247 |
uint32_t division_limit= key_cache->param_division_limit; |
|
1248 |
uint32_t age_threshold= key_cache->param_age_threshold; |
|
1249 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1250 |
||
1251 |
return(!resize_key_cache(key_cache, tmp_block_size, |
|
1252 |
tmp_buff_size, |
|
1253 |
division_limit, age_threshold)); |
|
1254 |
}
|
|
1255 |
||
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1256 |
sys_var_key_buffer_size::sys_var_key_buffer_size(sys_var_chain *chain, |
1257 |
const char *name_arg) |
|
1258 |
: sys_var_key_cache_param(chain, name_arg, |
|
1259 |
offsetof(KEY_CACHE, param_buff_size)) |
|
1260 |
{}
|
|
1
by brian
clean slate |
1261 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1262 |
bool sys_var_key_buffer_size::update(Session *session, set_var *var) |
1
by brian
clean slate |
1263 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
1264 |
uint64_t tmp= var->save_result.uint64_t_value; |
1
by brian
clean slate |
1265 |
KEY_CACHE *key_cache; |
1266 |
bool error= 0; |
|
1267 |
||
1268 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1106.4.2
by Brian Aker
Remove multi key cache |
1269 |
key_cache= dflt_key_cache; |
1
by brian
clean slate |
1270 |
|
1271 |
/*
|
|
1272 |
Abort if some other thread is changing the key cache
|
|
1273 |
TODO: This should be changed so that we wait until the previous
|
|
1274 |
assignment is done and then do the new assign
|
|
1275 |
*/
|
|
1276 |
if (key_cache->in_init) |
|
1277 |
goto end; |
|
1278 |
||
1106.4.2
by Brian Aker
Remove multi key cache |
1279 |
if (tmp == 0) // Zero size means delete |
1
by brian
clean slate |
1280 |
{
|
1106.4.2
by Brian Aker
Remove multi key cache |
1281 |
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, |
1282 |
ER_WARN_CANT_DROP_DEFAULT_KEYCACHE, |
|
1283 |
ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE)); |
|
1284 |
goto end; // Ignore default key cache |
|
1
by brian
clean slate |
1285 |
}
|
1286 |
||
1287 |
key_cache->param_buff_size= |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1288 |
(uint64_t) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
1289 |
|
1290 |
/* If key cache didn't existed initialize it, else resize it */
|
|
1291 |
key_cache->in_init= 1; |
|
1292 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1293 |
||
1106.4.2
by Brian Aker
Remove multi key cache |
1294 |
error= (bool)(resize_key_cache_with_lock(key_cache)); |
1
by brian
clean slate |
1295 |
|
1296 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1297 |
key_cache->in_init= 0; |
1
by brian
clean slate |
1298 |
|
1299 |
end: |
|
1300 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1301 |
return error; |
|
1302 |
}
|
|
1303 |
||
1304 |
||
1305 |
/**
|
|
1306 |
@todo
|
|
1307 |
Abort if some other thread is changing the key cache.
|
|
1308 |
This should be changed so that we wait until the previous
|
|
1309 |
assignment is done and then do the new assign
|
|
1310 |
*/
|
|
910.4.18
by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64 |
1311 |
bool sys_var_key_cache_uint32_t::update(Session *session, set_var *var) |
1
by brian
clean slate |
1312 |
{
|
622
by Brian Aker
More ulong work. |
1313 |
uint64_t tmp= (uint64_t) var->value->val_int(); |
1
by brian
clean slate |
1314 |
bool error= 0; |
1315 |
||
1316 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1317 |
||
1318 |
/*
|
|
1319 |
Abort if some other thread is changing the key cache
|
|
1320 |
TODO: This should be changed so that we wait until the previous
|
|
1321 |
assignment is done and then do the new assign
|
|
1322 |
*/
|
|
1106.4.2
by Brian Aker
Remove multi key cache |
1323 |
if (dflt_key_cache->in_init) |
1
by brian
clean slate |
1324 |
goto end; |
1325 |
||
1106.4.2
by Brian Aker
Remove multi key cache |
1326 |
*((uint32_t*) (((char*) dflt_key_cache) + offset))= |
910.4.18
by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64 |
1327 |
(uint32_t) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
1328 |
|
1329 |
/*
|
|
1330 |
Don't create a new key cache if it didn't exist
|
|
1331 |
(key_caches are created only when the user sets block_size)
|
|
1332 |
*/
|
|
1106.4.2
by Brian Aker
Remove multi key cache |
1333 |
dflt_key_cache->in_init= 1; |
1
by brian
clean slate |
1334 |
|
1335 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1336 |
||
1106.4.2
by Brian Aker
Remove multi key cache |
1337 |
error= (bool) (resize_key_cache_with_lock(dflt_key_cache)); |
1
by brian
clean slate |
1338 |
|
1339 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1106.4.2
by Brian Aker
Remove multi key cache |
1340 |
dflt_key_cache->in_init= 0; |
1
by brian
clean slate |
1341 |
|
1342 |
end: |
|
1343 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1344 |
return error; |
|
1345 |
}
|
|
1346 |
||
1347 |
||
1348 |
/****************************************************************************/
|
|
1349 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1350 |
bool sys_var_timestamp::update(Session *session, set_var *var) |
1
by brian
clean slate |
1351 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1352 |
session->set_time((time_t) var->save_result.uint64_t_value); |
1
by brian
clean slate |
1353 |
return 0; |
1354 |
}
|
|
1355 |
||
1356 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1357 |
void sys_var_timestamp::set_default(Session *session, enum_var_type) |
1
by brian
clean slate |
1358 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1359 |
session->user_time=0; |
1
by brian
clean slate |
1360 |
}
|
1361 |
||
1362 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1363 |
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1364 |
const LEX_STRING *) |
1
by brian
clean slate |
1365 |
{
|
1055.2.17
by Jay Pipes
More style cleanups in Session |
1366 |
session->sys_var_tmp.int32_t_value= (int32_t) session->start_time; |
1367 |
return (unsigned char*) &session->sys_var_tmp.int32_t_value; |
|
1
by brian
clean slate |
1368 |
}
|
1369 |
||
1370 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1371 |
bool sys_var_last_insert_id::update(Session *session, set_var *var) |
1
by brian
clean slate |
1372 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1373 |
session->first_successful_insert_id_in_prev_stmt= |
151
by Brian Aker
Ulonglong to uint64_t |
1374 |
var->save_result.uint64_t_value; |
1
by brian
clean slate |
1375 |
return 0; |
1376 |
}
|
|
1377 |
||
1378 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1379 |
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. |
1380 |
enum_var_type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1381 |
const LEX_STRING *) |
1
by brian
clean slate |
1382 |
{
|
1383 |
/*
|
|
77.1.45
by Monty Taylor
Warning fixes. |
1384 |
this tmp var makes it robust againt change of type of
|
1
by brian
clean slate |
1385 |
read_first_successful_insert_id_in_prev_stmt().
|
1386 |
*/
|
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1387 |
session->sys_var_tmp.uint64_t_value= |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1388 |
session->read_first_successful_insert_id_in_prev_stmt(); |
1389 |
return (unsigned char*) &session->sys_var_tmp.uint64_t_value; |
|
1
by brian
clean slate |
1390 |
}
|
1391 |
||
1392 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1393 |
bool sys_var_session_time_zone::check(Session *session, set_var *var) |
1
by brian
clean slate |
1394 |
{
|
1395 |
char buff[MAX_TIME_ZONE_NAME_LENGTH]; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1396 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci); |
1
by brian
clean slate |
1397 |
String *res= var->value->val_str(&str); |
1398 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1399 |
if (!(var->save_result.time_zone= my_tz_find(session, res))) |
1
by brian
clean slate |
1400 |
{
|
1401 |
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL"); |
|
1402 |
return 1; |
|
1403 |
}
|
|
1404 |
return 0; |
|
1405 |
}
|
|
1406 |
||
1407 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1408 |
bool sys_var_session_time_zone::update(Session *session, set_var *var) |
1
by brian
clean slate |
1409 |
{
|
1410 |
/* We are using Time_zone object found during check() phase. */
|
|
1411 |
if (var->type == OPT_GLOBAL) |
|
1412 |
{
|
|
1413 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1414 |
global_system_variables.time_zone= var->save_result.time_zone; |
|
1415 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1416 |
}
|
|
1417 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1418 |
session->variables.time_zone= var->save_result.time_zone; |
1
by brian
clean slate |
1419 |
return 0; |
1420 |
}
|
|
1421 |
||
1422 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1423 |
unsigned char *sys_var_session_time_zone::value_ptr(Session *session, |
1424 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1425 |
const LEX_STRING *) |
1
by brian
clean slate |
1426 |
{
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1427 |
/*
|
1
by brian
clean slate |
1428 |
We can use ptr() instead of c_ptr() here because String contaning
|
1429 |
time zone name is guaranteed to be zero ended.
|
|
1430 |
*/
|
|
1431 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
1432 |
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr()); |
1
by brian
clean slate |
1433 |
else
|
1434 |
{
|
|
1435 |
/*
|
|
1436 |
This is an ugly fix for replication: we don't replicate properly queries
|
|
1437 |
invoking system variables' values to update tables; but
|
|
1438 |
CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
|
|
1439 |
replicable (i.e. we tell the binlog code to store the session
|
|
1440 |
timezone). If it's the global value which was used we can't replicate
|
|
1441 |
(binlog code stores session value only).
|
|
1442 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1443 |
return (unsigned char *)(session->variables.time_zone->get_name()->ptr()); |
1
by brian
clean slate |
1444 |
}
|
1445 |
}
|
|
1446 |
||
1447 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1448 |
void sys_var_session_time_zone::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1449 |
{
|
1450 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1451 |
if (type == OPT_GLOBAL) |
|
1452 |
{
|
|
1453 |
if (default_tz_name) |
|
1454 |
{
|
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1455 |
String str(default_tz_name, &my_charset_utf8_general_ci); |
1
by brian
clean slate |
1456 |
/*
|
1457 |
We are guaranteed to find this time zone since its existence
|
|
1458 |
is checked during start-up.
|
|
1459 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1460 |
global_system_variables.time_zone= my_tz_find(session, &str); |
1
by brian
clean slate |
1461 |
}
|
1462 |
else
|
|
1463 |
global_system_variables.time_zone= my_tz_SYSTEM; |
|
1464 |
}
|
|
1465 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1466 |
session->variables.time_zone= global_system_variables.time_zone; |
1
by brian
clean slate |
1467 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1468 |
}
|
|
1469 |
||
1470 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1471 |
bool sys_var_session_lc_time_names::check(Session *, set_var *var) |
1
by brian
clean slate |
1472 |
{
|
1473 |
MY_LOCALE *locale_match; |
|
1474 |
||
1475 |
if (var->value->result_type() == INT_RESULT) |
|
1476 |
{
|
|
895
by Brian Aker
Completion (?) of uint conversion. |
1477 |
if (!(locale_match= my_locale_by_number((uint32_t) var->value->val_int()))) |
1
by brian
clean slate |
1478 |
{
|
1479 |
char buf[20]; |
|
1480 |
int10_to_str((int) var->value->val_int(), buf, -10); |
|
1481 |
my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf); |
|
1482 |
return 1; |
|
1483 |
}
|
|
1484 |
}
|
|
1485 |
else // STRING_RESULT |
|
1486 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1487 |
char buff[6]; |
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1488 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res; |
1
by brian
clean slate |
1489 |
if (!(res=var->value->val_str(&str))) |
1490 |
{
|
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
1491 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.c_str(), "NULL"); |
1
by brian
clean slate |
1492 |
return 1; |
1493 |
}
|
|
1494 |
const char *locale_str= res->c_ptr(); |
|
1495 |
if (!(locale_match= my_locale_by_name(locale_str))) |
|
1496 |
{
|
|
1497 |
my_printf_error(ER_UNKNOWN_ERROR, |
|
1498 |
"Unknown locale: '%s'", MYF(0), locale_str); |
|
1499 |
return 1; |
|
1500 |
}
|
|
1501 |
}
|
|
1502 |
||
1503 |
var->save_result.locale_value= locale_match; |
|
1504 |
return 0; |
|
1505 |
}
|
|
1506 |
||
1507 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1508 |
bool sys_var_session_lc_time_names::update(Session *session, set_var *var) |
1
by brian
clean slate |
1509 |
{
|
1510 |
if (var->type == OPT_GLOBAL) |
|
1511 |
global_system_variables.lc_time_names= var->save_result.locale_value; |
|
1512 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1513 |
session->variables.lc_time_names= var->save_result.locale_value; |
1
by brian
clean slate |
1514 |
return 0; |
1515 |
}
|
|
1516 |
||
1517 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1518 |
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. |
1519 |
enum_var_type type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1520 |
const LEX_STRING *) |
1
by brian
clean slate |
1521 |
{
|
1522 |
return type == OPT_GLOBAL ? |
|
481
by Brian Aker
Remove all of uchar. |
1523 |
(unsigned char *) global_system_variables.lc_time_names->name : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1524 |
(unsigned char *) session->variables.lc_time_names->name; |
1
by brian
clean slate |
1525 |
}
|
1526 |
||
1527 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1528 |
void sys_var_session_lc_time_names::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1529 |
{
|
1530 |
if (type == OPT_GLOBAL) |
|
1531 |
global_system_variables.lc_time_names= my_default_lc_time_names; |
|
1532 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1533 |
session->variables.lc_time_names= global_system_variables.lc_time_names; |
1
by brian
clean slate |
1534 |
}
|
1535 |
||
1536 |
/*
|
|
1537 |
Handling of microseoncds given as seconds.part_seconds
|
|
1538 |
||
1539 |
NOTES
|
|
1540 |
The argument to long query time is in seconds in decimal
|
|
151
by Brian Aker
Ulonglong to uint64_t |
1541 |
which is converted to uint64_t integer holding microseconds for storage.
|
1
by brian
clean slate |
1542 |
This is used for handling long_query_time
|
1543 |
*/
|
|
1544 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1545 |
bool sys_var_microseconds::update(Session *session, set_var *var) |
1
by brian
clean slate |
1546 |
{
|
1547 |
double num= var->value->val_real(); |
|
152
by Brian Aker
longlong replacement |
1548 |
int64_t microseconds; |
1
by brian
clean slate |
1549 |
if (num > (double) option_limits->max_value) |
1550 |
num= (double) option_limits->max_value; |
|
1551 |
if (num < (double) option_limits->min_value) |
|
1552 |
num= (double) option_limits->min_value; |
|
152
by Brian Aker
longlong replacement |
1553 |
microseconds= (int64_t) (num * 1000000.0 + 0.5); |
1
by brian
clean slate |
1554 |
if (var->type == OPT_GLOBAL) |
1555 |
{
|
|
1556 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1557 |
(global_system_variables.*offset)= microseconds; |
|
1558 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1559 |
}
|
|
1560 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1561 |
session->variables.*offset= microseconds; |
1
by brian
clean slate |
1562 |
return 0; |
1563 |
}
|
|
1564 |
||
1565 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1566 |
void sys_var_microseconds::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1567 |
{
|
152
by Brian Aker
longlong replacement |
1568 |
int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0); |
1
by brian
clean slate |
1569 |
if (type == OPT_GLOBAL) |
1570 |
{
|
|
1571 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1572 |
global_system_variables.*offset= microseconds; |
|
1573 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1574 |
}
|
|
1575 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1576 |
session->variables.*offset= microseconds; |
1
by brian
clean slate |
1577 |
}
|
1578 |
||
1579 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1580 |
Functions to update session->options bits
|
1
by brian
clean slate |
1581 |
*/
|
1582 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1583 |
static bool set_option_bit(Session *session, set_var *var) |
1
by brian
clean slate |
1584 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1585 |
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var); |
576
by Brian Aker
ulong conversion work |
1586 |
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1587 |
session->options&= ~sys_var->bit_flag; |
1
by brian
clean slate |
1588 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1589 |
session->options|= sys_var->bit_flag; |
1
by brian
clean slate |
1590 |
return 0; |
1591 |
}
|
|
1592 |
||
1593 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1594 |
static bool set_option_autocommit(Session *session, set_var *var) |
1
by brian
clean slate |
1595 |
{
|
1596 |
/* The test is negative as the flag we use is NOT autocommit */
|
|
1597 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1598 |
uint64_t org_options= session->options; |
1
by brian
clean slate |
1599 |
|
576
by Brian Aker
ulong conversion work |
1600 |
if (var->save_result.uint32_t_value != 0) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1601 |
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag; |
1
by brian
clean slate |
1602 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1603 |
session->options|= ((sys_var_session_bit*) var->var)->bit_flag; |
1
by brian
clean slate |
1604 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1605 |
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT) |
1
by brian
clean slate |
1606 |
{
|
1607 |
if ((org_options & OPTION_NOT_AUTOCOMMIT)) |
|
1608 |
{
|
|
1609 |
/* We changed to auto_commit mode */
|
|
1172.1.2
by Brian Aker
Remove worthless call (ok... for not current replication system). |
1610 |
session->options&= ~(uint64_t) (OPTION_BEGIN); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1611 |
session->transaction.all.modified_non_trans_table= false; |
1612 |
session->server_status|= SERVER_STATUS_AUTOCOMMIT; |
|
1613 |
if (ha_commit(session)) |
|
1
by brian
clean slate |
1614 |
return 1; |
1615 |
}
|
|
1616 |
else
|
|
1617 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1618 |
session->transaction.all.modified_non_trans_table= false; |
1619 |
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT; |
|
1
by brian
clean slate |
1620 |
}
|
1621 |
}
|
|
1622 |
return 0; |
|
1623 |
}
|
|
1624 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1625 |
static int check_pseudo_thread_id(Session *, set_var *var) |
1
by brian
clean slate |
1626 |
{
|
151
by Brian Aker
Ulonglong to uint64_t |
1627 |
var->save_result.uint64_t_value= var->value->val_int(); |
1
by brian
clean slate |
1628 |
return 0; |
1629 |
}
|
|
1630 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1631 |
static unsigned char *get_warning_count(Session *session) |
1
by brian
clean slate |
1632 |
{
|
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
1633 |
session->sys_var_tmp.uint32_t_value= |
626
by Brian Aker
More of the same (ulong/64) |
1634 |
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] + |
1635 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] + |
|
1636 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_WARN]); |
|
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
1637 |
return (unsigned char*) &session->sys_var_tmp.uint32_t_value; |
1
by brian
clean slate |
1638 |
}
|
1639 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1640 |
static unsigned char *get_error_count(Session *session) |
1
by brian
clean slate |
1641 |
{
|
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
1642 |
session->sys_var_tmp.uint32_t_value= |
626
by Brian Aker
More of the same (ulong/64) |
1643 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR]; |
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
1644 |
return (unsigned char*) &session->sys_var_tmp.uint32_t_value; |
1
by brian
clean slate |
1645 |
}
|
1646 |
||
1647 |
||
1648 |
/**
|
|
1649 |
Get the tmpdir that was specified or chosen by default.
|
|
1650 |
||
1651 |
This is necessary because if the user does not specify a temporary
|
|
1652 |
directory via the command line, one is chosen based on the environment
|
|
575.4.3
by ysano
Rename mysql to drizzle. |
1653 |
or system defaults. But we can't just always use drizzle_tmpdir, because
|
1
by brian
clean slate |
1654 |
that is actually a call to my_tmpdir() which cycles among possible
|
1655 |
temporary directories.
|
|
1656 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1657 |
@param session thread handle
|
1
by brian
clean slate |
1658 |
|
1659 |
@retval
|
|
1660 |
ptr pointer to NUL-terminated string
|
|
1661 |
*/
|
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1662 |
static unsigned char *get_tmpdir(Session *) |
1
by brian
clean slate |
1663 |
{
|
680
by Brian Aker
Remove locks around temp tables for searching tmp directory path. |
1664 |
assert(drizzle_tmpdir); |
575.4.3
by ysano
Rename mysql to drizzle. |
1665 |
return (unsigned char*)drizzle_tmpdir; |
1
by brian
clean slate |
1666 |
}
|
1667 |
||
1668 |
/****************************************************************************
|
|
1669 |
Main handling of variables:
|
|
1670 |
- Initialisation
|
|
1671 |
- Searching during parsing
|
|
1672 |
- Update loop
|
|
1673 |
****************************************************************************/
|
|
1674 |
||
1675 |
/**
|
|
1676 |
Find variable name in option my_getopt structure used for
|
|
1677 |
command line args.
|
|
1678 |
||
1679 |
@param opt option structure array to search in
|
|
1680 |
@param name variable name
|
|
1681 |
||
1682 |
@retval
|
|
1683 |
0 Error
|
|
1684 |
@retval
|
|
1685 |
ptr pointer to option structure
|
|
1686 |
*/
|
|
1687 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1688 |
static struct my_option *find_option(struct my_option *opt, const char *name) |
1
by brian
clean slate |
1689 |
{
|
482
by Brian Aker
Remove uint. |
1690 |
uint32_t length=strlen(name); |
1
by brian
clean slate |
1691 |
for (; opt->name; opt++) |
1692 |
{
|
|
1693 |
if (!getopt_compare_strings(opt->name, name, length) && |
|
1694 |
!opt->name[length]) |
|
1695 |
{
|
|
1696 |
/*
|
|
1697 |
Only accept the option if one can set values through it.
|
|
1698 |
If not, there is no default value or limits in the option.
|
|
1699 |
*/
|
|
1700 |
return (opt->value) ? opt : 0; |
|
1701 |
}
|
|
1702 |
}
|
|
1703 |
return 0; |
|
1704 |
}
|
|
1705 |
||
1706 |
||
1707 |
/*
|
|
1708 |
Add variables to the dynamic hash of system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1709 |
|
1
by brian
clean slate |
1710 |
SYNOPSIS
|
1711 |
mysql_add_sys_var_chain()
|
|
1712 |
first Pointer to first system variable to add
|
|
1713 |
long_opt (optional)command line arguments may be tied for limit checks.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1714 |
|
1
by brian
clean slate |
1715 |
RETURN VALUES
|
1716 |
0 SUCCESS
|
|
1717 |
otherwise FAILURE
|
|
1718 |
*/
|
|
1719 |
||
1720 |
||
1721 |
int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options) |
|
1722 |
{
|
|
1723 |
sys_var *var; |
|
1724 |
/* A write lock should be held on LOCK_system_variables_hash */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1725 |
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1726 |
for (var= first; var; var= var->getNext()) |
1
by brian
clean slate |
1727 |
{
|
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1728 |
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1729 |
string lower_name(var->getName()); |
1730 |
transform(lower_name.begin(), lower_name.end(), |
|
1731 |
lower_name.begin(), ::tolower); |
|
1732 |
||
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1733 |
/* this fails if there is a conflicting variable name. */
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1734 |
if (system_variable_map.find(lower_name) != system_variable_map.end()) |
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1735 |
{
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1736 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Variable named %s already exists!\n"), |
1737 |
var->getName().c_str()); |
|
1022.2.37
by Monty Taylor
Moved more tolower calls to setup rather than during runtime. |
1738 |
return 1; |
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1739 |
}
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1740 |
|
1741 |
pair<SystemVariableMap::iterator, bool> ret= |
|
1742 |
system_variable_map.insert(make_pair(lower_name, var)); |
|
1743 |
if (ret.second == false) |
|
1744 |
{
|
|
1745 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Could not add Variable: %s\n"), |
|
1746 |
var->getName().c_str()); |
|
1747 |
return 1; |
|
1748 |
}
|
|
1749 |
||
1
by brian
clean slate |
1750 |
if (long_options) |
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1751 |
var->setOptionLimits(find_option(long_options, var->getName().c_str())); |
1
by brian
clean slate |
1752 |
}
|
1753 |
return 0; |
|
1754 |
||
1755 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1756 |
|
1757 |
||
1
by brian
clean slate |
1758 |
/*
|
1759 |
Remove variables to the dynamic hash of system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1760 |
|
1
by brian
clean slate |
1761 |
SYNOPSIS
|
1762 |
mysql_del_sys_var_chain()
|
|
1763 |
first Pointer to first system variable to remove
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1764 |
|
1
by brian
clean slate |
1765 |
RETURN VALUES
|
1766 |
0 SUCCESS
|
|
1767 |
otherwise FAILURE
|
|
1768 |
*/
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1769 |
|
1
by brian
clean slate |
1770 |
int mysql_del_sys_var_chain(sys_var *first) |
1771 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1772 |
|
1
by brian
clean slate |
1773 |
/* A write lock should be held on LOCK_system_variables_hash */
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1774 |
for (sys_var *var= first; var; var= var->getNext()) |
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1775 |
{
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1776 |
string lower_name(var->getName()); |
1777 |
transform(lower_name.begin(), lower_name.end(), |
|
1778 |
lower_name.begin(), ::tolower); |
|
1779 |
system_variable_map.erase(lower_name); |
|
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1780 |
}
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1781 |
return 0; |
1
by brian
clean slate |
1782 |
}
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1783 |
|
1784 |
||
1785 |
||
1
by brian
clean slate |
1786 |
/*
|
1787 |
Constructs an array of system variables for display to the user.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1788 |
|
1
by brian
clean slate |
1789 |
SYNOPSIS
|
1790 |
enumerate_sys_vars()
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1791 |
session current thread
|
1
by brian
clean slate |
1792 |
sorted If TRUE, the system variables should be sorted
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1793 |
|
1
by brian
clean slate |
1794 |
RETURN VALUES
|
1795 |
pointer Array of SHOW_VAR elements for display
|
|
1796 |
NULL FAILURE
|
|
1797 |
*/
|
|
1798 |
||
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1799 |
SHOW_VAR* enumerate_sys_vars(Session *session, bool) |
1
by brian
clean slate |
1800 |
{
|
1801 |
int fixed_count= fixed_show_vars.elements; |
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1802 |
int size= sizeof(SHOW_VAR) * (system_variable_map.size() + fixed_count + 1); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1803 |
SHOW_VAR *result= (SHOW_VAR*) session->alloc(size); |
1
by brian
clean slate |
1804 |
|
1805 |
if (result) |
|
1806 |
{
|
|
1807 |
SHOW_VAR *show= result + fixed_count; |
|
1808 |
memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(SHOW_VAR)); |
|
1809 |
||
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1810 |
SystemVariableMap::const_iterator iter= system_variable_map.begin(); |
1811 |
while (iter != system_variable_map.end()) |
|
1
by brian
clean slate |
1812 |
{
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1813 |
sys_var *var= (*iter).second; |
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1814 |
show->name= var->getName().c_str(); |
1
by brian
clean slate |
1815 |
show->value= (char*) var; |
1816 |
show->type= SHOW_SYS; |
|
1817 |
show++; |
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1818 |
++iter; |
1
by brian
clean slate |
1819 |
}
|
1820 |
||
1821 |
/* make last element empty */
|
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
1822 |
memset(show, 0, sizeof(SHOW_VAR)); |
1
by brian
clean slate |
1823 |
}
|
1824 |
return result; |
|
1825 |
}
|
|
1826 |
||
1827 |
||
1828 |
/*
|
|
1829 |
Initialize the system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1830 |
|
1
by brian
clean slate |
1831 |
SYNOPSIS
|
1832 |
set_var_init()
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1833 |
|
1
by brian
clean slate |
1834 |
RETURN VALUES
|
1835 |
0 SUCCESS
|
|
1836 |
otherwise FAILURE
|
|
1837 |
*/
|
|
1838 |
||
1839 |
int set_var_init() |
|
1840 |
{
|
|
482
by Brian Aker
Remove uint. |
1841 |
uint32_t count= 0; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1842 |
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1843 |
for (sys_var *var= vars.first; var; var= var->getNext(), count++) {}; |
1
by brian
clean slate |
1844 |
|
1845 |
if (my_init_dynamic_array(&fixed_show_vars, sizeof(SHOW_VAR), |
|
1846 |
FIXED_VARS_SIZE + 64, 64)) |
|
1847 |
goto error; |
|
1848 |
||
1849 |
fixed_show_vars.elements= FIXED_VARS_SIZE; |
|
1850 |
memcpy(fixed_show_vars.buffer, fixed_vars, sizeof(fixed_vars)); |
|
1851 |
||
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1852 |
vars.last->setNext(NULL); |
1
by brian
clean slate |
1853 |
if (mysql_add_sys_var_chain(vars.first, my_long_options)) |
1854 |
goto error; |
|
1855 |
||
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1856 |
return(0); |
1
by brian
clean slate |
1857 |
|
1858 |
error: |
|
1859 |
fprintf(stderr, "failed to initialize system variables"); |
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1860 |
return(1); |
1
by brian
clean slate |
1861 |
}
|
1862 |
||
1863 |
||
1864 |
void set_var_free() |
|
1865 |
{
|
|
1866 |
delete_dynamic(&fixed_show_vars); |
|
1867 |
}
|
|
1868 |
||
1869 |
||
1870 |
/*
|
|
1871 |
Add elements to the dynamic list of read-only system variables.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1872 |
|
1
by brian
clean slate |
1873 |
SYNOPSIS
|
1874 |
mysql_append_static_vars()
|
|
1875 |
show_vars Pointer to start of array
|
|
1876 |
count Number of elements
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1877 |
|
1
by brian
clean slate |
1878 |
RETURN VALUES
|
1879 |
0 SUCCESS
|
|
1880 |
otherwise FAILURE
|
|
1881 |
*/
|
|
482
by Brian Aker
Remove uint. |
1882 |
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count) |
1
by brian
clean slate |
1883 |
{
|
1884 |
for (; count > 0; count--, show_vars++) |
|
481
by Brian Aker
Remove all of uchar. |
1885 |
if (insert_dynamic(&fixed_show_vars, (unsigned char*) show_vars)) |
1
by brian
clean slate |
1886 |
return 1; |
1887 |
return 0; |
|
1888 |
}
|
|
1889 |
||
1890 |
||
1891 |
/**
|
|
1892 |
Find a user set-table variable.
|
|
1893 |
||
1894 |
@param str Name of system variable to find
|
|
1895 |
@param length Length of variable. zero means that we should use strlen()
|
|
1896 |
on the variable
|
|
1897 |
@param no_error Refuse to emit an error, even if one occurred.
|
|
1898 |
||
1899 |
@retval
|
|
1900 |
pointer pointer to variable definitions
|
|
1901 |
@retval
|
|
1902 |
0 Unknown variable (error message is given)
|
|
1903 |
*/
|
|
1904 |
||
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
1905 |
sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error) |
1
by brian
clean slate |
1906 |
{
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1907 |
string lower_name(str); |
1908 |
transform(lower_name.begin(), lower_name.end(), |
|
1909 |
lower_name.begin(), ::tolower); |
|
1910 |
||
1911 |
sys_var *result= NULL; |
|
1912 |
||
1913 |
SystemVariableMap::iterator iter= system_variable_map.find(lower_name); |
|
1914 |
if (iter != system_variable_map.end()) |
|
1915 |
{
|
|
1916 |
result= (*iter).second; |
|
1917 |
}
|
|
1918 |
||
1
by brian
clean slate |
1919 |
/*
|
1920 |
This function is only called from the sql_plugin.cc.
|
|
1921 |
A lock on LOCK_system_variable_hash should be held
|
|
1922 |
*/
|
|
1022.2.37
by Monty Taylor
Moved more tolower calls to setup rather than during runtime. |
1923 |
if (result == NULL) |
896.1.1
by Monty Taylor
Actually return NULL from intern_find_sys_var on error thank you. |
1924 |
{
|
1925 |
if (no_error) |
|
1926 |
{
|
|
1927 |
return NULL; |
|
1928 |
}
|
|
1929 |
else
|
|
1930 |
{
|
|
1931 |
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); |
|
1932 |
return NULL; |
|
1933 |
}
|
|
1934 |
}
|
|
1
by brian
clean slate |
1935 |
|
1022.2.37
by Monty Taylor
Moved more tolower calls to setup rather than during runtime. |
1936 |
return result; |
1
by brian
clean slate |
1937 |
}
|
1938 |
||
1939 |
||
1940 |
/**
|
|
1941 |
Execute update of all variables.
|
|
1942 |
||
1943 |
First run a check of all variables that all updates will go ok.
|
|
1944 |
If yes, then execute all updates, returning an error if any one failed.
|
|
1945 |
||
1946 |
This should ensure that in all normal cases none all or variables are
|
|
1947 |
updated.
|
|
1948 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1949 |
@param Session Thread id
|
1
by brian
clean slate |
1950 |
@param var_list List of variables to update
|
1951 |
||
1952 |
@retval
|
|
1953 |
0 ok
|
|
1954 |
@retval
|
|
1955 |
1 ERROR, message sent (normally no variables was updated)
|
|
1956 |
@retval
|
|
1957 |
-1 ERROR, message not sent
|
|
1958 |
*/
|
|
1959 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1960 |
int sql_set_variables(Session *session, List<set_var_base> *var_list) |
1
by brian
clean slate |
1961 |
{
|
1962 |
int error; |
|
1963 |
List_iterator_fast<set_var_base> it(*var_list); |
|
1964 |
||
1965 |
set_var_base *var; |
|
1966 |
while ((var=it++)) |
|
1967 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1968 |
if ((error= var->check(session))) |
1
by brian
clean slate |
1969 |
goto err; |
1970 |
}
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1971 |
if (!(error= test(session->is_error()))) |
1
by brian
clean slate |
1972 |
{
|
1973 |
it.rewind(); |
|
1974 |
while ((var= it++)) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1975 |
error|= var->update(session); // Returns 0, -1 or 1 |
1
by brian
clean slate |
1976 |
}
|
1977 |
||
1978 |
err: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1979 |
free_underlaid_joins(session, &session->lex->select_lex); |
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1980 |
return(error); |
1
by brian
clean slate |
1981 |
}
|
1982 |
||
1983 |
||
1984 |
/*****************************************************************************
|
|
1985 |
Functions to handle SET mysql_internal_variable=const_expr
|
|
1986 |
*****************************************************************************/
|
|
1987 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1988 |
int set_var::check(Session *session) |
1
by brian
clean slate |
1989 |
{
|
1990 |
if (var->is_readonly()) |
|
1991 |
{
|
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1992 |
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->getName().c_str(), "read only"); |
1
by brian
clean slate |
1993 |
return -1; |
1994 |
}
|
|
1995 |
if (var->check_type(type)) |
|
1996 |
{
|
|
1997 |
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE; |
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1998 |
my_error(err, MYF(0), var->getName().c_str()); |
1
by brian
clean slate |
1999 |
return -1; |
2000 |
}
|
|
2001 |
/* value is a NULL pointer if we are using SET ... = DEFAULT */
|
|
2002 |
if (!value) |
|
2003 |
{
|
|
2004 |
if (var->check_default(type)) |
|
2005 |
{
|
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
2006 |
my_error(ER_NO_DEFAULT, MYF(0), var->getName().c_str()); |
1
by brian
clean slate |
2007 |
return -1; |
2008 |
}
|
|
2009 |
return 0; |
|
2010 |
}
|
|
2011 |
||
2012 |
if ((!value->fixed && |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2013 |
value->fix_fields(session, &value)) || value->check_cols(1)) |
1
by brian
clean slate |
2014 |
return -1; |
2015 |
if (var->check_update_type(value->result_type())) |
|
2016 |
{
|
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
2017 |
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->getName().c_str()); |
1
by brian
clean slate |
2018 |
return -1; |
2019 |
}
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2020 |
return var->check(session, this) ? -1 : 0; |
1
by brian
clean slate |
2021 |
}
|
2022 |
||
2023 |
/**
|
|
2024 |
Update variable
|
|
2025 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2026 |
@param session thread handler
|
1
by brian
clean slate |
2027 |
@returns 0|1 ok or ERROR
|
2028 |
||
2029 |
@note ERROR can be only due to abnormal operations involving
|
|
2030 |
the server's execution evironment such as
|
|
2031 |
out of memory, hard disk failure or the computer blows up.
|
|
2032 |
Consider set_var::check() method if there is a need to return
|
|
2033 |
an error due to logics.
|
|
2034 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2035 |
int set_var::update(Session *session) |
1
by brian
clean slate |
2036 |
{
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
2037 |
if (! value) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2038 |
var->set_default(session, type); |
2039 |
else if (var->update(session, this)) |
|
1
by brian
clean slate |
2040 |
return -1; // should never happen |
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
2041 |
if (var->getAfterUpdateTrigger()) |
2042 |
(*var->getAfterUpdateTrigger())(session, type); |
|
1
by brian
clean slate |
2043 |
return 0; |
2044 |
}
|
|
2045 |
||
2046 |
/*****************************************************************************
|
|
2047 |
Functions to handle SET @user_variable=const_expr
|
|
2048 |
*****************************************************************************/
|
|
2049 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2050 |
int set_var_user::check(Session *session) |
1
by brian
clean slate |
2051 |
{
|
2052 |
/*
|
|
2053 |
Item_func_set_user_var can't substitute something else on its place =>
|
|
2054 |
0 can be passed as last argument (reference on item)
|
|
2055 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2056 |
return (user_var_item->fix_fields(session, (Item**) 0) || |
1
by brian
clean slate |
2057 |
user_var_item->check(0)) ? -1 : 0; |
2058 |
}
|
|
2059 |
||
2060 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2061 |
int set_var_user::update(Session *) |
1
by brian
clean slate |
2062 |
{
|
2063 |
if (user_var_item->update()) |
|
2064 |
{
|
|
2065 |
/* Give an error if it's not given already */
|
|
2066 |
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0)); |
|
2067 |
return -1; |
|
2068 |
}
|
|
2069 |
return 0; |
|
2070 |
}
|
|
2071 |
||
2072 |
/****************************************************************************
|
|
2073 |
Functions to handle table_type
|
|
2074 |
****************************************************************************/
|
|
2075 |
||
2076 |
/* Based upon sys_var::check_enum() */
|
|
2077 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2078 |
bool sys_var_session_storage_engine::check(Session *session, set_var *var) |
1
by brian
clean slate |
2079 |
{
|
2080 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
2081 |
const char *value; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
2082 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res; |
1
by brian
clean slate |
2083 |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
2084 |
var->save_result.storage_engine= NULL; |
1
by brian
clean slate |
2085 |
if (var->value->result_type() == STRING_RESULT) |
2086 |
{
|
|
1095.3.32
by Stewart Smith
misc codestyle fixes. usually around if ( and associated conditions |
2087 |
res= var->value->val_str(&str); |
2088 |
if (res == NULL || res->ptr() == NULL) |
|
1
by brian
clean slate |
2089 |
{
|
1095.3.9
by Stewart Smith
refactor ha_resolve_by_name to accept std::string instead of LEX_STRING |
2090 |
value= "NULL"; |
1
by brian
clean slate |
2091 |
goto err; |
2092 |
}
|
|
1095.3.9
by Stewart Smith
refactor ha_resolve_by_name to accept std::string instead of LEX_STRING |
2093 |
else
|
2094 |
{
|
|
2095 |
const std::string engine_name(res->ptr()); |
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
2096 |
plugin::StorageEngine *engine; |
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
2097 |
var->save_result.storage_engine= plugin::StorageEngine::findByName(*session, engine_name); |
1095.3.32
by Stewart Smith
misc codestyle fixes. usually around if ( and associated conditions |
2098 |
if (var->save_result.storage_engine == NULL) |
1095.3.9
by Stewart Smith
refactor ha_resolve_by_name to accept std::string instead of LEX_STRING |
2099 |
{
|
2100 |
value= res->c_ptr(); |
|
2101 |
goto err; |
|
2102 |
}
|
|
1095.3.32
by Stewart Smith
misc codestyle fixes. usually around if ( and associated conditions |
2103 |
engine= var->save_result.storage_engine; |
1095.3.9
by Stewart Smith
refactor ha_resolve_by_name to accept std::string instead of LEX_STRING |
2104 |
}
|
1
by brian
clean slate |
2105 |
return 0; |
2106 |
}
|
|
2107 |
value= "unknown"; |
|
2108 |
||
2109 |
err: |
|
2110 |
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value); |
|
2111 |
return 1; |
|
2112 |
}
|
|
2113 |
||
2114 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2115 |
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session, |
2116 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
2117 |
const LEX_STRING *) |
1
by brian
clean slate |
2118 |
{
|
481
by Brian Aker
Remove all of uchar. |
2119 |
unsigned char* result; |
968.2.29
by Monty Taylor
First steps towards new plugin reg. |
2120 |
string engine_name; |
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
2121 |
plugin::StorageEngine *engine= session->variables.*offset; |
1
by brian
clean slate |
2122 |
if (type == OPT_GLOBAL) |
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
2123 |
engine= global_system_variables.*offset; |
971.1.14
by Monty Taylor
Slurp around strings rather than char* for storage engine name. |
2124 |
engine_name= engine->getName(); |
968.2.29
by Monty Taylor
First steps towards new plugin reg. |
2125 |
result= (unsigned char *) session->strmake(engine_name.c_str(), |
2126 |
engine_name.size()); |
|
1
by brian
clean slate |
2127 |
return result; |
2128 |
}
|
|
2129 |
||
2130 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2131 |
void sys_var_session_storage_engine::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
2132 |
{
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
2133 |
plugin::StorageEngine *old_value, *new_value, **value; |
1
by brian
clean slate |
2134 |
if (type == OPT_GLOBAL) |
2135 |
{
|
|
2136 |
value= &(global_system_variables.*offset); |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
2137 |
new_value= myisam_engine; |
1
by brian
clean slate |
2138 |
}
|
2139 |
else
|
|
2140 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2141 |
value= &(session->variables.*offset); |
971.1.19
by Monty Taylor
Remove most of plugin_ref. Fix several leaks (where the malloc was happening but never freed). One step away from no more plugin_ref. Yippee. It's so much easier the second time you try to do this. |
2142 |
new_value= global_system_variables.*offset; |
1
by brian
clean slate |
2143 |
}
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
2144 |
assert(new_value); |
1
by brian
clean slate |
2145 |
old_value= *value; |
2146 |
*value= new_value; |
|
2147 |
}
|
|
2148 |
||
2149 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2150 |
bool sys_var_session_storage_engine::update(Session *session, set_var *var) |
1
by brian
clean slate |
2151 |
{
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
2152 |
plugin::StorageEngine **value= &(global_system_variables.*offset), *old_value; |
1
by brian
clean slate |
2153 |
if (var->type != OPT_GLOBAL) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2154 |
value= &(session->variables.*offset); |
1
by brian
clean slate |
2155 |
old_value= *value; |
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
2156 |
if (old_value != var->save_result.storage_engine) |
1
by brian
clean slate |
2157 |
{
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
2158 |
*value= var->save_result.storage_engine; |
1
by brian
clean slate |
2159 |
}
|
2160 |
return 0; |
|
2161 |
}
|
|
2162 |
||
2163 |
bool
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2164 |
sys_var_session_optimizer_switch:: |
617
by Brian Aker
ulong fixes |
2165 |
symbolic_mode_representation(Session *session, uint32_t val, LEX_STRING *rep) |
1
by brian
clean slate |
2166 |
{
|
2167 |
char buff[STRING_BUFFER_USUAL_SIZE*8]; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
2168 |
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci); |
1
by brian
clean slate |
2169 |
|
2170 |
tmp.length(0); |
|
2171 |
||
482
by Brian Aker
Remove uint. |
2172 |
for (uint32_t i= 0; val; val>>= 1, i++) |
1
by brian
clean slate |
2173 |
{
|
2174 |
if (val & 1) |
|
2175 |
{
|
|
2176 |
tmp.append(optimizer_switch_typelib.type_names[i], |
|
2177 |
optimizer_switch_typelib.type_lengths[i]); |
|
2178 |
tmp.append(','); |
|
2179 |
}
|
|
2180 |
}
|
|
2181 |
||
2182 |
if (tmp.length()) |
|
2183 |
tmp.length(tmp.length() - 1); /* trim the trailing comma */ |
|
2184 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2185 |
rep->str= session->strmake(tmp.ptr(), tmp.length()); |
1
by brian
clean slate |
2186 |
|
2187 |
rep->length= rep->str ? tmp.length() : 0; |
|
2188 |
||
2189 |
return rep->length != tmp.length(); |
|
2190 |
}
|
|
2191 |
||
2192 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
2193 |
unsigned char *sys_var_session_optimizer_switch::value_ptr(Session *session, |
2194 |
enum_var_type type, |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
2195 |
const LEX_STRING *) |
1
by brian
clean slate |
2196 |
{
|
2197 |
LEX_STRING opts; |
|
892.2.2
by Monty Taylor
More solaris warnings. |
2198 |
uint32_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2199 |
session->variables.*offset); |
2200 |
(void) symbolic_mode_representation(session, val, &opts); |
|
481
by Brian Aker
Remove all of uchar. |
2201 |
return (unsigned char *) opts.str; |
1
by brian
clean slate |
2202 |
}
|
2203 |
||
2204 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
2205 |
void sys_var_session_optimizer_switch::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
2206 |
{
|
2207 |
if (type == OPT_GLOBAL) |
|
2208 |
global_system_variables.*offset= 0; |
|
2209 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2210 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
2211 |
}
|
2212 |
||
2213 |