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