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