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 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
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. |
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 |
*/
|
|
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. |
40 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
41 |
#include <config.h> |
42 |
#include <drizzled/option.h> |
|
43 |
#include <drizzled/error.h> |
|
44 |
#include <drizzled/gettext.h> |
|
45 |
#include <drizzled/tztime.h> |
|
46 |
#include <drizzled/data_home.h> |
|
47 |
#include <drizzled/set_var.h> |
|
48 |
#include <drizzled/session.h> |
|
49 |
#include <drizzled/sql_base.h> |
|
50 |
#include <drizzled/lock.h> |
|
51 |
#include <drizzled/item/uint.h> |
|
52 |
#include <drizzled/item/null.h> |
|
53 |
#include <drizzled/item/float.h> |
|
54 |
#include <drizzled/item/string.h> |
|
55 |
#include <drizzled/plugin.h> |
|
56 |
#include <drizzled/version.h> |
|
57 |
#include <drizzled/internal/m_string.h> |
|
58 |
#include <drizzled/pthread_globals.h> |
|
59 |
#include <drizzled/charset.h> |
|
60 |
#include <drizzled/transaction_services.h> |
|
61 |
#include <drizzled/constrained_value.h> |
|
62 |
#include <drizzled/visibility.h> |
|
63 |
#include <drizzled/typelib.h> |
|
64 |
#include <drizzled/plugin/storage_engine.h> |
|
2241.3.2
by Olaf van der Spek
Refactor Session::variables |
65 |
#include <drizzled/system_variables.h> |
2241.3.14
by Olaf van der Spek
Refactor |
66 |
#include <drizzled/catalog/instance.h> |
1
by brian
clean slate |
67 |
|
1502.3.1
by iwamatsu at nigauri
Add cstdio include to files needing it. Fixes the build on some debian |
68 |
#include <cstdio> |
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
69 |
#include <map> |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
70 |
#include <vector> |
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
71 |
#include <algorithm> |
72 |
||
73 |
using namespace std; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
74 |
|
2241.3.14
by Olaf van der Spek
Refactor |
75 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
76 |
|
77 |
namespace internal |
|
78 |
{
|
|
2241.3.14
by Olaf van der Spek
Refactor |
79 |
extern bool timed_mutexes; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
80 |
}
|
873.2.16
by Monty Taylor
Replaced HASH with std::map - avoid utf8 hashing on every sys_var lookup. |
81 |
|
1241.9.32
by Monty Taylor
Moved global myisam and heap pointers out of server_includes. |
82 |
extern plugin::StorageEngine *myisam_engine; |
1251.2.3
by Jay Pipes
Merge trunk and resolve conflicts |
83 |
extern bool timed_mutexes; |
1241.9.27
by Monty Taylor
Removed mysys/m_sys.h from server_includes.h. |
84 |
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
85 |
extern struct option my_long_options[]; |
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
86 |
extern const charset_info_st *character_set_filesystem; |
629.2.7
by Monty Taylor
Fixed a couple of memory buffer size issues. |
87 |
extern size_t my_thread_stack_size; |
1
by brian
clean slate |
88 |
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
89 |
typedef map<string, sys_var *> SystemVariableMap; |
90 |
static SystemVariableMap system_variable_map; |
|
670.2.4
by Monty Taylor
Removed more stuff from the headers. |
91 |
extern char *opt_drizzle_tmpdir; |
1
by brian
clean slate |
92 |
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
93 |
extern TYPELIB tx_isolation_typelib; |
94 |
||
2183.1.2
by Monty Taylor
A slew of tiny meaningless changes. |
95 |
namespace
|
96 |
{
|
|
97 |
static size_t revno= DRIZZLE7_VC_REVNO; |
|
98 |
static size_t release_id= DRIZZLE7_RELEASE_ID; |
|
99 |
}
|
|
100 |
||
461
by Monty Taylor
Removed NullS. bu-bye. |
101 |
const char *bool_type_names[]= { "OFF", "ON", NULL }; |
1
by brian
clean slate |
102 |
TYPELIB bool_typelib= |
103 |
{
|
|
104 |
array_elements(bool_type_names)-1, "", bool_type_names, NULL |
|
105 |
};
|
|
106 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
107 |
static bool set_option_bit(Session *session, set_var *var); |
108 |
static bool set_option_autocommit(Session *session, set_var *var); |
|
109 |
static int check_pseudo_thread_id(Session *session, set_var *var); |
|
110 |
static int check_tx_isolation(Session *session, set_var *var); |
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
111 |
static void fix_tx_isolation(Session *session, sql_var_t type); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
112 |
static int check_completion_type(Session *session, set_var *var); |
1273.13.24
by Brian Aker
Updating style, simplified code. |
113 |
static void fix_completion_type(Session *session, sql_var_t type); |
114 |
static void fix_max_join_size(Session *session, sql_var_t type); |
|
115 |
static void fix_session_mem_root(Session *session, sql_var_t type); |
|
116 |
static void fix_server_id(Session *session, sql_var_t type); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
117 |
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
118 |
const std::string &name, int64_t val); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
119 |
static unsigned char *get_error_count(Session *session); |
120 |
static unsigned char *get_warning_count(Session *session); |
|
121 |
static unsigned char *get_tmpdir(Session *session); |
|
1
by brian
clean slate |
122 |
|
123 |
/*
|
|
124 |
Variable definition list
|
|
125 |
||
126 |
These are variables that can be set from the command line, in
|
|
127 |
alphabetic order.
|
|
128 |
||
129 |
The variables are linked into the list. A variable is added to
|
|
130 |
it in the constructor (see sys_var class for details).
|
|
131 |
*/
|
|
819.1.1
by Toru Maesaka
Removed the 16bit limitation of auto_increment_(increment|offset) system variables |
132 |
static sys_var_session_uint64_t |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
133 |
sys_auto_increment_increment("auto_increment_increment", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
134 |
&drizzle_system_variables::auto_increment_increment); |
819.1.1
by Toru Maesaka
Removed the 16bit limitation of auto_increment_(increment|offset) system variables |
135 |
static sys_var_session_uint64_t |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
136 |
sys_auto_increment_offset("auto_increment_offset", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
137 |
&drizzle_system_variables::auto_increment_offset); |
1
by brian
clean slate |
138 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
139 |
static sys_var_fs_path sys_basedir("basedir", basedir); |
140 |
static sys_var_fs_path sys_pid_file("pid_file", pid_file); |
|
141 |
static sys_var_fs_path sys_plugin_dir("plugin_dir", plugin_dir); |
|
1813.2.7
by Monty Taylor
Migrated plugin_dir to fs::path. |
142 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
143 |
static sys_var_size_t_ptr sys_thread_stack_size("thread_stack", |
1813.2.8
by Monty Taylor
Removed the fixed_vars. |
144 |
&my_thread_stack_size); |
1897.4.1
by Monty Taylor
Added readonly constrained_value class. |
145 |
static sys_var_constrained_value_readonly<uint32_t> sys_back_log("back_log", back_log); |
1813.2.8
by Monty Taylor
Removed the fixed_vars. |
146 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
147 |
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
148 |
&drizzle_system_variables::bulk_insert_buff_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
149 |
static sys_var_session_uint32_t sys_completion_type("completion_type", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
150 |
&drizzle_system_variables::completion_type, |
619
by Brian Aker
Removed ulong methods from vars. |
151 |
check_completion_type, |
152 |
fix_completion_type); |
|
1
by brian
clean slate |
153 |
static sys_var_collation_sv |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
154 |
sys_collation_server("collation_server", &drizzle_system_variables::collation_server, &default_charset_info); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
155 |
static sys_var_fs_path sys_datadir("datadir", getDataHome()); |
1
by brian
clean slate |
156 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
157 |
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
158 |
&drizzle_system_variables::join_buff_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
159 |
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
160 |
&drizzle_system_variables::max_allowed_packet); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
161 |
static sys_var_session_uint64_t sys_max_error_count("max_error_count", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
162 |
&drizzle_system_variables::max_error_count); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
163 |
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
164 |
&drizzle_system_variables::max_heap_table_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
165 |
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
166 |
&drizzle_system_variables::pseudo_thread_id, |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
167 |
0, check_pseudo_thread_id); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
168 |
static sys_var_session_ha_rows sys_max_join_size("max_join_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
169 |
&drizzle_system_variables::max_join_size, |
617
by Brian Aker
ulong fixes |
170 |
fix_max_join_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
171 |
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
172 |
&drizzle_system_variables::max_seeks_for_key); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
173 |
static sys_var_session_uint64_t sys_max_length_for_sort_data("max_length_for_sort_data", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
174 |
&drizzle_system_variables::max_length_for_sort_data); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
175 |
static sys_var_session_size_t sys_max_sort_length("max_sort_length", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
176 |
&drizzle_system_variables::max_sort_length); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
177 |
static sys_var_uint64_t_ptr sys_max_write_lock_count("max_write_lock_count", |
622.1.1
by Brian Aker
32bit fixes around vars |
178 |
&max_write_lock_count); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
179 |
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
180 |
&drizzle_system_variables::min_examined_row_limit); |
1
by brian
clean slate |
181 |
|
182 |
/* these two cannot be static */
|
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
183 |
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
184 |
&drizzle_system_variables::optimizer_prune_level); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
185 |
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
186 |
&drizzle_system_variables::optimizer_search_depth); |
1
by brian
clean slate |
187 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
188 |
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
189 |
&drizzle_system_variables::preload_buff_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
190 |
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
191 |
&drizzle_system_variables::read_buff_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
192 |
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
193 |
&drizzle_system_variables::read_rnd_buff_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
194 |
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
195 |
&drizzle_system_variables::div_precincrement); |
1
by brian
clean slate |
196 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
197 |
static sys_var_session_size_t sys_range_alloc_block_size("range_alloc_block_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
198 |
&drizzle_system_variables::range_alloc_block_size); |
1938.3.1
by David Shrewsbury
Add --replicate-query option. |
199 |
|
200 |
static sys_var_session_bool sys_replicate_query("replicate_query", |
|
201 |
&drizzle_system_variables::replicate_query); |
|
202 |
||
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
203 |
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
204 |
&drizzle_system_variables::query_alloc_block_size, |
1831.1.1
by Andrew Hutchings
Fix new warnings in GCC 4.5 |
205 |
NULL, fix_session_mem_root); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
206 |
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
207 |
&drizzle_system_variables::query_prealloc_size, |
1831.1.1
by Andrew Hutchings
Fix new warnings in GCC 4.5 |
208 |
NULL, fix_session_mem_root); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
209 |
static sys_var_readonly sys_tmpdir("tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir); |
1
by brian
clean slate |
210 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
211 |
static sys_var_fs_path sys_secure_file_priv("secure_file_priv", |
1813.2.6
by Monty Taylor
Made secure_file_priv be an fs::path from the beginning. |
212 |
secure_file_priv); |
1555.1.1
by Joe Daly
fix to display scheduler in show variables |
213 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
214 |
static sys_var_const_str_ptr sys_scheduler("scheduler", |
1794.3.2
by Andrew Hutchings
Re-enabled scheduler option. |
215 |
(char**)&opt_scheduler); |
1555.1.1
by Joe Daly
fix to display scheduler in show variables |
216 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
217 |
static sys_var_uint32_t_ptr sys_server_id("server_id", &server_id, |
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. |
218 |
fix_server_id); |
219 |
||
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
220 |
static sys_var_session_size_t sys_sort_buffer("sort_buffer_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
221 |
&drizzle_system_variables::sortbuff_size); |
1
by brian
clean slate |
222 |
|
2132.3.1
by Andrew Hutchings
Make transaction_message_threshold a read-only global variable instead of a per-session variable |
223 |
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold", |
224 |
&transaction_message_threshold); |
|
1802.14.2
by Joseph Daly
fix up transaction_message_threshold |
225 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
226 |
static sys_var_session_storage_engine sys_storage_engine("storage_engine", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
227 |
&drizzle_system_variables::storage_engine); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
228 |
static sys_var_size_t_ptr sys_table_def_size("table_definition_cache", |
1226.1.3
by Brian Aker
Possible solution for hash/rehash. |
229 |
&table_def_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
230 |
static sys_var_uint64_t_ptr sys_table_cache_size("table_open_cache", |
1
by brian
clean slate |
231 |
&table_cache_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
232 |
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout("table_lock_wait_timeout", |
1
by brian
clean slate |
233 |
&table_lock_wait_timeout); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
234 |
static sys_var_session_enum sys_tx_isolation("tx_isolation", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
235 |
&drizzle_system_variables::tx_isolation, |
617
by Brian Aker
ulong fixes |
236 |
&tx_isolation_typelib, |
237 |
fix_tx_isolation, |
|
238 |
check_tx_isolation); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
239 |
static sys_var_session_uint64_t sys_tmp_table_size("tmp_table_size", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
240 |
&drizzle_system_variables::tmp_table_size); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
241 |
static sys_var_bool_ptr sys_timed_mutexes("timed_mutexes", &internal::timed_mutexes); |
242 |
static sys_var_const_str sys_version("version", version().c_str()); |
|
1228.1.10
by Monty Taylor
Version, length, transaction_log. |
243 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
244 |
static sys_var_const_str sys_version_comment("version_comment", |
546
by Monty Taylor
Cleaned up version.h. (And by cleaned, I mean removed) |
245 |
COMPILATION_COMMENT); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
246 |
static sys_var_const_str sys_version_compile_machine("version_compile_machine", |
1081.1.1
by Monty Taylor
Whole boat-load of build fixes. |
247 |
HOST_CPU); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
248 |
static sys_var_const_str sys_version_compile_os("version_compile_os", |
1081.1.1
by Monty Taylor
Whole boat-load of build fixes. |
249 |
HOST_OS); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
250 |
static sys_var_const_str sys_version_compile_vendor("version_compile_vendor", |
1081.1.1
by Monty Taylor
Whole boat-load of build fixes. |
251 |
HOST_VENDOR); |
1
by brian
clean slate |
252 |
|
520.1.21
by Brian Aker
THD -> Session rename |
253 |
/* Variables that are bits in Session */
|
1
by brian
clean slate |
254 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
255 |
sys_var_session_bit sys_autocommit("autocommit", 0, |
1
by brian
clean slate |
256 |
set_option_autocommit, |
257 |
OPTION_NOT_AUTOCOMMIT, |
|
258 |
1); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
259 |
static sys_var_session_bit sys_big_selects("sql_big_selects", 0, |
1
by brian
clean slate |
260 |
set_option_bit, |
261 |
OPTION_BIG_SELECTS); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
262 |
static sys_var_session_bit sys_sql_warnings("sql_warnings", 0, |
1
by brian
clean slate |
263 |
set_option_bit, |
264 |
OPTION_WARNINGS); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
265 |
static sys_var_session_bit sys_sql_notes("sql_notes", 0, |
1
by brian
clean slate |
266 |
set_option_bit, |
267 |
OPTION_SQL_NOTES); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
268 |
static sys_var_session_bit sys_buffer_results("sql_buffer_result", 0, |
1
by brian
clean slate |
269 |
set_option_bit, |
270 |
OPTION_BUFFER_RESULT); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
271 |
static sys_var_session_bit sys_foreign_key_checks("foreign_key_checks", 0, |
1
by brian
clean slate |
272 |
set_option_bit, |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
273 |
OPTION_NO_FOREIGN_KEY_CHECKS, 1); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
274 |
static sys_var_session_bit sys_unique_checks("unique_checks", 0, |
1
by brian
clean slate |
275 |
set_option_bit, |
1018
by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication). |
276 |
OPTION_RELAXED_UNIQUE_CHECKS, 1); |
1
by brian
clean slate |
277 |
/* Local state variables */
|
278 |
||
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
279 |
static sys_var_session_ha_rows sys_select_limit("sql_select_limit", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
280 |
&drizzle_system_variables::select_limit); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
281 |
static sys_var_timestamp sys_timestamp("timestamp"); |
1
by brian
clean slate |
282 |
static sys_var_last_insert_id |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
283 |
sys_last_insert_id("last_insert_id"); |
1
by brian
clean slate |
284 |
/*
|
285 |
identity is an alias for last_insert_id(), so that we are compatible
|
|
286 |
with Sybase
|
|
287 |
*/
|
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
288 |
static sys_var_last_insert_id sys_identity("identity"); |
1
by brian
clean slate |
289 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
290 |
static sys_var_session_lc_time_names sys_lc_time_names("lc_time_names"); |
1
by brian
clean slate |
291 |
|
292 |
/*
|
|
293 |
We want statements referring explicitly to @@session.insert_id to be
|
|
294 |
unsafe, because insert_id is modified internally by the slave sql
|
|
295 |
thread when NULL values are inserted in an AUTO_INCREMENT column.
|
|
296 |
This modification interfers with the value of the
|
|
297 |
@@session.insert_id variable if @@session.insert_id is referred
|
|
298 |
explicitly by an insert statement (as is seen by executing "SET
|
|
299 |
@@session.insert_id=0; CREATE TABLE t (a INT, b INT KEY
|
|
300 |
AUTO_INCREMENT); INSERT INTO t(a) VALUES (@@session.insert_id);" in
|
|
301 |
statement-based logging mode: t will be different on master and
|
|
302 |
slave).
|
|
303 |
*/
|
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
304 |
static sys_var_readonly sys_error_count("error_count", |
626
by Brian Aker
More of the same (ulong/64) |
305 |
OPT_SESSION, |
937.2.3
by Stewart Smith
yet another 4/8byte long issue with variables. Fix up warning and error count to use uint32_t instead. |
306 |
SHOW_INT, |
626
by Brian Aker
More of the same (ulong/64) |
307 |
get_error_count); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
308 |
static sys_var_readonly sys_warning_count("warning_count", |
626
by Brian Aker
More of the same (ulong/64) |
309 |
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. |
310 |
SHOW_INT, |
626
by Brian Aker
More of the same (ulong/64) |
311 |
get_warning_count); |
1
by brian
clean slate |
312 |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
313 |
sys_var_session_uint64_t sys_group_concat_max_len("group_concat_max_len", |
1878.3.2
by Monty Taylor
Split out show_type into its own header and made sys_var work through |
314 |
&drizzle_system_variables::group_concat_max_len); |
1
by brian
clean slate |
315 |
|
316 |
/* Global read-only variable containing hostname */
|
|
2183.1.2
by Monty Taylor
A slew of tiny meaningless changes. |
317 |
static sys_var_const_string sys_hostname("hostname", getServerHostname()); |
318 |
||
319 |
static sys_var_const_str sys_revid("vc_revid", DRIZZLE7_VC_REVID); |
|
320 |
static sys_var_const_str sys_branch("vc_branch", DRIZZLE7_VC_BRANCH); |
|
321 |
static sys_var_size_t_ptr_readonly sys_revno("vc_revno", &revno); |
|
322 |
static sys_var_size_t_ptr_readonly sys_release_id("vc_release_id", &release_id); |
|
1
by brian
clean slate |
323 |
|
1976.2.10
by Monty Taylor
Add ability to add a validation function to any sys_var. duh. |
324 |
bool sys_var::check(Session *session, set_var *var) |
1
by brian
clean slate |
325 |
{
|
1976.2.10
by Monty Taylor
Add ability to add a validation function to any sys_var. duh. |
326 |
if (check_func) |
327 |
{
|
|
328 |
int res; |
|
329 |
if ((res=(*check_func)(session, var)) < 0) |
|
330 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr()); |
|
331 |
return res; |
|
332 |
}
|
|
2070.2.1
by Monty Taylor
First step in getting that anonymous union out of set_var. |
333 |
var->updateValue(); |
1
by brian
clean slate |
334 |
return 0; |
335 |
}
|
|
336 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
337 |
bool sys_var_str::check(Session *session, set_var *var) |
1
by brian
clean slate |
338 |
{
|
1976.2.10
by Monty Taylor
Add ability to add a validation function to any sys_var. duh. |
339 |
if (!check_func) |
340 |
return 0; |
|
341 |
||
1
by brian
clean slate |
342 |
int res; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
343 |
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. |
344 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr()); |
1
by brian
clean slate |
345 |
return res; |
346 |
}
|
|
347 |
||
1945.1.2
by Monty Taylor
Add better support in constrained_check for min/max support. Add string ref class. |
348 |
bool sys_var_std_string::check(Session *session, set_var *var) |
349 |
{
|
|
350 |
if (check_func == NULL) |
|
351 |
{
|
|
352 |
return false; |
|
353 |
}
|
|
354 |
||
355 |
int res= (*check_func)(session, var); |
|
356 |
if (res != 0) |
|
357 |
{
|
|
358 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr()); |
|
359 |
return true; |
|
360 |
}
|
|
361 |
return false; |
|
362 |
}
|
|
363 |
||
1
by brian
clean slate |
364 |
/*
|
365 |
Functions to check and update variables
|
|
366 |
*/
|
|
367 |
||
368 |
||
369 |
/**
|
|
370 |
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
|
|
371 |
*/
|
|
372 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
373 |
static void fix_max_join_size(Session *session, sql_var_t type) |
1
by brian
clean slate |
374 |
{
|
375 |
if (type != OPT_GLOBAL) |
|
376 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
377 |
if (session->variables.max_join_size == HA_POS_ERROR) |
378 |
session->options|= OPTION_BIG_SELECTS; |
|
1
by brian
clean slate |
379 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
380 |
session->options&= ~OPTION_BIG_SELECTS; |
1
by brian
clean slate |
381 |
}
|
382 |
}
|
|
383 |
||
384 |
||
385 |
/**
|
|
386 |
Can't change the 'next' tx_isolation while we are already in
|
|
387 |
a transaction
|
|
388 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
389 |
static int check_tx_isolation(Session *session, set_var *var) |
1
by brian
clean slate |
390 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
391 |
if (var->type == OPT_DEFAULT && (session->server_status & SERVER_STATUS_IN_TRANS)) |
1
by brian
clean slate |
392 |
{
|
393 |
my_error(ER_CANT_CHANGE_TX_ISOLATION, MYF(0)); |
|
394 |
return 1; |
|
395 |
}
|
|
396 |
return 0; |
|
397 |
}
|
|
398 |
||
399 |
/*
|
|
400 |
If one doesn't use the SESSION modifier, the isolation level
|
|
401 |
is only active for the next command.
|
|
402 |
*/
|
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
403 |
static void fix_tx_isolation(Session *session, sql_var_t type) |
1
by brian
clean slate |
404 |
{
|
405 |
if (type == OPT_SESSION) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
406 |
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. |
407 |
session->variables.tx_isolation); |
1
by brian
clean slate |
408 |
}
|
409 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
410 |
static void fix_completion_type(Session *, sql_var_t) {} |
1
by brian
clean slate |
411 |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
412 |
static int check_completion_type(Session *, set_var *var) |
1
by brian
clean slate |
413 |
{
|
152
by Brian Aker
longlong replacement |
414 |
int64_t val= var->value->val_int(); |
1
by brian
clean slate |
415 |
if (val < 0 || val > 2) |
416 |
{
|
|
417 |
char buf[64]; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
418 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->getName().c_str(), internal::llstr(val, buf)); |
1
by brian
clean slate |
419 |
return 1; |
420 |
}
|
|
421 |
return 0; |
|
422 |
}
|
|
423 |
||
424 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
425 |
static void fix_session_mem_root(Session *session, sql_var_t type) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
426 |
{
|
427 |
if (type != OPT_GLOBAL) |
|
1485
by Brian Aker
Updates to confine memroot |
428 |
session->mem_root->reset_root_defaults(session->variables.query_alloc_block_size, |
429 |
session->variables.query_prealloc_size); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
430 |
}
|
431 |
||
432 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
433 |
static void fix_server_id(Session *, sql_var_t) |
1
by brian
clean slate |
434 |
{
|
435 |
}
|
|
436 |
||
437 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
438 |
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
439 |
const std::string &name, int64_t val) |
1
by brian
clean slate |
440 |
{
|
441 |
if (fixed) |
|
442 |
{
|
|
2148.5.3
by Brian Aker
Remove hard coded array for numbers (this also fixes a couple of spots where |
443 |
char buf[DECIMAL_LONGLONG_DIGITS]; |
1
by brian
clean slate |
444 |
|
445 |
if (unsignd) |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
446 |
internal::ullstr((uint64_t) val, buf); |
1
by brian
clean slate |
447 |
else
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
448 |
internal::llstr(val, buf); |
1
by brian
clean slate |
449 |
|
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
450 |
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, |
1
by brian
clean slate |
451 |
ER_TRUNCATED_WRONG_VALUE, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
452 |
ER(ER_TRUNCATED_WRONG_VALUE), name.c_str(), buf); |
1
by brian
clean slate |
453 |
}
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
454 |
return false; |
1
by brian
clean slate |
455 |
}
|
456 |
||
1251.2.2
by Jay Pipes
Pulls MyISAM-specific server variables into the MyISAM |
457 |
uint64_t fix_unsigned(Session *session, uint64_t num, |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
458 |
const struct option *option_limits) |
1
by brian
clean slate |
459 |
{
|
143
by Brian Aker
Bool cleanup. |
460 |
bool fixed= false; |
151
by Brian Aker
Ulonglong to uint64_t |
461 |
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed); |
1
by brian
clean slate |
462 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
463 |
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num); |
1
by brian
clean slate |
464 |
return out; |
465 |
}
|
|
466 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
467 |
|
468 |
static size_t fix_size_t(Session *session, size_t num, |
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
469 |
const struct option *option_limits) |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
470 |
{
|
471 |
bool fixed= false; |
|
472 |
size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed); |
|
473 |
||
474 |
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num); |
|
475 |
return out; |
|
476 |
}
|
|
477 |
||
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
478 |
bool sys_var_uint32_t_ptr::check(Session *, set_var *var) |
479 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
480 |
var->updateValue(); |
1
by brian
clean slate |
481 |
return 0; |
482 |
}
|
|
483 |
||
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. |
484 |
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var) |
485 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
486 |
uint64_t tmp= var->getInteger(); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
487 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
488 |
||
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. |
489 |
if (option_limits) |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
490 |
{
|
491 |
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits); |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
492 |
if(static_cast<uint64_t>(newvalue) == tmp) |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
493 |
*value= newvalue; |
494 |
}
|
|
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. |
495 |
else
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
496 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
497 |
*value= static_cast<uint32_t>(tmp); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
498 |
}
|
499 |
||
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. |
500 |
return 0; |
501 |
}
|
|
502 |
||
503 |
||
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
504 |
void sys_var_uint32_t_ptr::set_default(Session *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. |
505 |
{
|
506 |
bool not_used; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
507 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
892.2.2
by Monty Taylor
More solaris warnings. |
508 |
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value, |
509 |
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. |
510 |
}
|
511 |
||
1
by brian
clean slate |
512 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
513 |
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var) |
1
by brian
clean slate |
514 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
515 |
uint64_t tmp= var->getInteger(); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
516 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
517 |
||
1
by brian
clean slate |
518 |
if (option_limits) |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
519 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
520 |
uint64_t newvalue= fix_unsigned(session, tmp, option_limits); |
910.4.10
by Stewart Smith
fix system variables for correct endian architectures. |
521 |
if(newvalue==tmp) |
522 |
*value= newvalue; |
|
523 |
}
|
|
1
by brian
clean slate |
524 |
else
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
525 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
526 |
*value= tmp; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
527 |
}
|
528 |
||
1
by brian
clean slate |
529 |
return 0; |
530 |
}
|
|
531 |
||
532 |
||
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
533 |
void sys_var_uint64_t_ptr::set_default(Session *session, sql_var_t) |
1
by brian
clean slate |
534 |
{
|
1897.4.14
by Monty Taylor
Update to support default values and properly throw warnings on value |
535 |
if (have_default_value) |
536 |
{
|
|
537 |
*value= default_value; |
|
538 |
}
|
|
539 |
else
|
|
540 |
{
|
|
541 |
bool not_used; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
542 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
1897.4.14
by Monty Taylor
Update to support default values and properly throw warnings on value |
543 |
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value, |
544 |
option_limits, ¬_used); |
|
545 |
}
|
|
1
by brian
clean slate |
546 |
}
|
547 |
||
548 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
549 |
bool sys_var_size_t_ptr::update(Session *session, set_var *var) |
550 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
551 |
size_t tmp= size_t(var->getInteger()); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
552 |
|
553 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
|
554 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
555 |
if (option_limits) |
556 |
*value= fix_size_t(session, tmp, option_limits); |
|
557 |
else
|
|
558 |
*value= tmp; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
559 |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
560 |
return 0; |
561 |
}
|
|
562 |
||
563 |
||
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
564 |
void sys_var_size_t_ptr::set_default(Session *session, sql_var_t) |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
565 |
{
|
566 |
bool not_used; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
567 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
568 |
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value, |
569 |
option_limits, ¬_used); |
|
570 |
}
|
|
571 |
||
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
572 |
bool sys_var_bool_ptr::check(Session *session, set_var *var) |
573 |
{
|
|
574 |
return check_enum(session, var, &bool_typelib); |
|
575 |
}
|
|
576 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
577 |
bool sys_var_bool_ptr::update(Session *, set_var *var) |
1
by brian
clean slate |
578 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
579 |
*value= bool(var->getInteger()); |
1
by brian
clean slate |
580 |
return 0; |
581 |
}
|
|
582 |
||
583 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
584 |
void sys_var_bool_ptr::set_default(Session *, sql_var_t) |
1
by brian
clean slate |
585 |
{
|
1964.2.16
by Monty Taylor
took care of innodb SessionVAR usage. |
586 |
*value= default_value; |
146
by Brian Aker
my_bool cleanup. |
587 |
}
|
588 |
||
1
by brian
clean slate |
589 |
|
615
by Brian Aker
Added 32bit system variable support |
590 |
/*
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
591 |
32 bit types for session variables
|
615
by Brian Aker
Added 32bit system variable support |
592 |
*/
|
593 |
bool sys_var_session_uint32_t::check(Session *session, set_var *var) |
|
594 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
595 |
var->updateValue(); |
596 |
return (check_func && (*check_func)(session, var)); |
|
615
by Brian Aker
Added 32bit system variable support |
597 |
}
|
598 |
||
599 |
bool sys_var_session_uint32_t::update(Session *session, set_var *var) |
|
600 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
601 |
uint64_t tmp= var->getInteger(); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
602 |
|
615
by Brian Aker
Added 32bit system variable support |
603 |
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
604 |
if ((uint32_t) tmp > max_system_variables.*offset) |
|
605 |
{
|
|
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. |
606 |
throw_bounds_warning(session, true, true, getName(), (int64_t) tmp); |
615
by Brian Aker
Added 32bit system variable support |
607 |
tmp= max_system_variables.*offset; |
608 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
609 |
|
615
by Brian Aker
Added 32bit system variable support |
610 |
if (option_limits) |
611 |
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits); |
|
612 |
else if (tmp > UINT32_MAX) |
|
613 |
{
|
|
614 |
tmp= UINT32_MAX; |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
615 |
throw_bounds_warning(session, true, true, getName(), int64_t(var->getInteger())); |
615
by Brian Aker
Added 32bit system variable support |
616 |
}
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
617 |
|
615
by Brian Aker
Added 32bit system variable support |
618 |
if (var->type == OPT_GLOBAL) |
619 |
global_system_variables.*offset= (uint32_t) tmp; |
|
620 |
else
|
|
621 |
session->variables.*offset= (uint32_t) tmp; |
|
622 |
||
623 |
return 0; |
|
624 |
}
|
|
625 |
||
626 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
627 |
void sys_var_session_uint32_t::set_default(Session *session, sql_var_t type) |
615
by Brian Aker
Added 32bit system variable support |
628 |
{
|
629 |
if (type == OPT_GLOBAL) |
|
630 |
{
|
|
631 |
bool not_used; |
|
632 |
/* We will not come here if option_limits is not set */
|
|
633 |
global_system_variables.*offset= |
|
634 |
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value, |
|
635 |
option_limits, ¬_used); |
|
636 |
}
|
|
637 |
else
|
|
638 |
session->variables.*offset= global_system_variables.*offset; |
|
639 |
}
|
|
640 |
||
641 |
||
642 |
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session, |
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
643 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
644 |
const LEX_STRING *) |
615
by Brian Aker
Added 32bit system variable support |
645 |
{
|
646 |
if (type == OPT_GLOBAL) |
|
647 |
return (unsigned char*) &(global_system_variables.*offset); |
|
648 |
return (unsigned char*) &(session->variables.*offset); |
|
649 |
}
|
|
650 |
||
1
by brian
clean slate |
651 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
652 |
bool sys_var_session_ha_rows::update(Session *session, set_var *var) |
1
by brian
clean slate |
653 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
654 |
uint64_t tmp= var->getInteger(); |
1
by brian
clean slate |
655 |
|
656 |
/* Don't use bigger value than given with --maximum-variable-name=.. */
|
|
657 |
if ((ha_rows) tmp > max_system_variables.*offset) |
|
658 |
tmp= max_system_variables.*offset; |
|
659 |
||
660 |
if (option_limits) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
661 |
tmp= (ha_rows) fix_unsigned(session, tmp, option_limits); |
1
by brian
clean slate |
662 |
if (var->type == OPT_GLOBAL) |
663 |
{
|
|
664 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
665 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
1
by brian
clean slate |
666 |
global_system_variables.*offset= (ha_rows) tmp; |
667 |
}
|
|
668 |
else
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
669 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
670 |
session->variables.*offset= (ha_rows) tmp; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
671 |
}
|
672 |
||
1
by brian
clean slate |
673 |
return 0; |
674 |
}
|
|
675 |
||
676 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
677 |
void sys_var_session_ha_rows::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
678 |
{
|
679 |
if (type == OPT_GLOBAL) |
|
680 |
{
|
|
143
by Brian Aker
Bool cleanup. |
681 |
bool not_used; |
1
by brian
clean slate |
682 |
/* We will not come here if option_limits is not set */
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
683 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
1
by brian
clean slate |
684 |
global_system_variables.*offset= |
685 |
(ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value, |
|
686 |
option_limits, ¬_used); |
|
687 |
}
|
|
688 |
else
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
689 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
690 |
session->variables.*offset= global_system_variables.*offset; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
691 |
}
|
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 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
706 |
var->updateValue(); |
707 |
return (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 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
712 |
uint64_t tmp= var->getInteger(); |
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 */
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
725 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
151
by Brian Aker
Ulonglong to uint64_t |
726 |
global_system_variables.*offset= (uint64_t) tmp; |
1
by brian
clean slate |
727 |
}
|
728 |
else
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
729 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
730 |
session->variables.*offset= (uint64_t) tmp; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
731 |
}
|
732 |
||
1
by brian
clean slate |
733 |
return 0; |
734 |
}
|
|
735 |
||
736 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
737 |
void sys_var_session_uint64_t::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
738 |
{
|
739 |
if (type == OPT_GLOBAL) |
|
740 |
{
|
|
143
by Brian Aker
Bool cleanup. |
741 |
bool not_used; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
742 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
1
by brian
clean slate |
743 |
global_system_variables.*offset= |
151
by Brian Aker
Ulonglong to uint64_t |
744 |
getopt_ull_limit_value((uint64_t) option_limits->def_value, |
1
by brian
clean slate |
745 |
option_limits, ¬_used); |
746 |
}
|
|
747 |
else
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
748 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
749 |
session->variables.*offset= global_system_variables.*offset; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
750 |
}
|
1
by brian
clean slate |
751 |
}
|
752 |
||
753 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
754 |
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
755 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
756 |
const LEX_STRING *) |
1
by brian
clean slate |
757 |
{
|
758 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
759 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
760 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
761 |
}
|
762 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
763 |
bool sys_var_session_size_t::check(Session *session, set_var *var) |
764 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
765 |
var->updateValue(); |
766 |
return (check_func && (*check_func)(session, var)); |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
767 |
}
|
768 |
||
769 |
bool sys_var_session_size_t::update(Session *session, set_var *var) |
|
770 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
771 |
size_t tmp= size_t(var->getInteger()); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
772 |
|
773 |
if (tmp > max_system_variables.*offset) |
|
774 |
tmp= max_system_variables.*offset; |
|
775 |
||
776 |
if (option_limits) |
|
777 |
tmp= fix_size_t(session, tmp, option_limits); |
|
778 |
if (var->type == OPT_GLOBAL) |
|
779 |
{
|
|
780 |
/* Lock is needed to make things safe on 32 bit systems */
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
781 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
782 |
global_system_variables.*offset= tmp; |
783 |
}
|
|
784 |
else
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
785 |
{
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
786 |
session->variables.*offset= tmp; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
787 |
}
|
788 |
||
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
789 |
return 0; |
790 |
}
|
|
791 |
||
792 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
793 |
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. |
794 |
{
|
795 |
if (type == OPT_GLOBAL) |
|
796 |
{
|
|
797 |
bool not_used; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
798 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
799 |
global_system_variables.*offset= |
892.2.2
by Monty Taylor
More solaris warnings. |
800 |
(size_t)getopt_ull_limit_value((size_t) option_limits->def_value, |
801 |
option_limits, ¬_used); |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
802 |
}
|
803 |
else
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
804 |
{
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
805 |
session->variables.*offset= global_system_variables.*offset; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
806 |
}
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
807 |
}
|
808 |
||
809 |
||
810 |
unsigned char *sys_var_session_size_t::value_ptr(Session *session, |
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
811 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
812 |
const LEX_STRING *) |
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
813 |
{
|
814 |
if (type == OPT_GLOBAL) |
|
815 |
return (unsigned char*) &(global_system_variables.*offset); |
|
816 |
return (unsigned char*) &(session->variables.*offset); |
|
817 |
}
|
|
818 |
||
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
819 |
bool sys_var_session_bool::check(Session *session, set_var *var) |
820 |
{
|
|
821 |
return check_enum(session, var, &bool_typelib); |
|
822 |
}
|
|
1
by brian
clean slate |
823 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
824 |
bool sys_var_session_bool::update(Session *session, set_var *var) |
1
by brian
clean slate |
825 |
{
|
826 |
if (var->type == OPT_GLOBAL) |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
827 |
global_system_variables.*offset= bool(var->getInteger()); |
1
by brian
clean slate |
828 |
else
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
829 |
session->variables.*offset= bool(var->getInteger()); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
830 |
|
1
by brian
clean slate |
831 |
return 0; |
832 |
}
|
|
833 |
||
834 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
835 |
void sys_var_session_bool::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
836 |
{
|
837 |
if (type == OPT_GLOBAL) |
|
200
by Brian Aker
my_bool from handler and set_var |
838 |
global_system_variables.*offset= (bool) option_limits->def_value; |
1
by brian
clean slate |
839 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
840 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
841 |
}
|
842 |
||
843 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
844 |
unsigned char *sys_var_session_bool::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
845 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
846 |
const LEX_STRING *) |
1
by brian
clean slate |
847 |
{
|
848 |
if (type == OPT_GLOBAL) |
|
481
by Brian Aker
Remove all of uchar. |
849 |
return (unsigned char*) &(global_system_variables.*offset); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
850 |
return (unsigned char*) &(session->variables.*offset); |
1
by brian
clean slate |
851 |
}
|
852 |
||
853 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
854 |
bool sys_var::check_enum(Session *, |
77.1.45
by Monty Taylor
Warning fixes. |
855 |
set_var *var, const TYPELIB *enum_names) |
1
by brian
clean slate |
856 |
{
|
857 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
858 |
const char *value; |
|
859 |
String str(buff, sizeof(buff), system_charset_info), *res; |
|
860 |
||
861 |
if (var->value->result_type() == STRING_RESULT) |
|
862 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
863 |
res= var->value->val_str(&str); |
864 |
if (res == NULL) |
|
1
by brian
clean slate |
865 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
866 |
value= "NULL"; |
1
by brian
clean slate |
867 |
goto err; |
868 |
}
|
|
971.2.1
by Eric Day
Fix for bug #311025. This was due to code that was removed during ulong cleanup (r576). |
869 |
|
2151.5.4
by Olaf van der Spek
Move strfunc functions into TYPELIB class |
870 |
uint64_t tmp_val= enum_names->find_type(res->ptr(), res->length(), true); |
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
871 |
if (tmp_val == 0) |
872 |
{
|
|
873 |
value= res->c_ptr(); |
|
874 |
goto err; |
|
875 |
}
|
|
876 |
var->setValue(tmp_val-1); |
|
1
by brian
clean slate |
877 |
}
|
878 |
else
|
|
879 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
880 |
uint64_t tmp= var->value->val_int(); |
1
by brian
clean slate |
881 |
if (tmp >= enum_names->count) |
882 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
883 |
internal::llstr(tmp,buff); |
1
by brian
clean slate |
884 |
value=buff; // Wrong value is here |
885 |
goto err; |
|
886 |
}
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
887 |
var->setValue(tmp); // Save for update |
1
by brian
clean slate |
888 |
}
|
889 |
return 0; |
|
890 |
||
891 |
err: |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
892 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.c_str(), value); |
1
by brian
clean slate |
893 |
return 1; |
894 |
}
|
|
895 |
||
896 |
||
897 |
/**
|
|
898 |
Return an Item for a variable.
|
|
899 |
||
900 |
Used with @@[global.]variable_name.
|
|
901 |
||
902 |
If type is not given, return local value if exists, else global.
|
|
903 |
*/
|
|
904 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
905 |
Item *sys_var::item(Session *session, sql_var_t var_type, const LEX_STRING *base) |
1
by brian
clean slate |
906 |
{
|
907 |
if (check_type(var_type)) |
|
908 |
{
|
|
909 |
if (var_type != OPT_DEFAULT) |
|
910 |
{
|
|
911 |
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
912 |
name.c_str(), var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); |
1
by brian
clean slate |
913 |
return 0; |
914 |
}
|
|
915 |
/* As there was no local variable, return the global value */
|
|
916 |
var_type= OPT_GLOBAL; |
|
917 |
}
|
|
918 |
switch (show_type()) { |
|
625
by Brian Aker
ulong/64 bit straighten out. |
919 |
case SHOW_LONG: |
1
by brian
clean slate |
920 |
case SHOW_INT: |
921 |
{
|
|
482
by Brian Aker
Remove uint. |
922 |
uint32_t value; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
923 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
924 |
value= *(uint*) value_ptr(session, var_type, base); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
925 |
|
151
by Brian Aker
Ulonglong to uint64_t |
926 |
return new Item_uint((uint64_t) value); |
1
by brian
clean slate |
927 |
}
|
928 |
case SHOW_LONGLONG: |
|
929 |
{
|
|
152
by Brian Aker
longlong replacement |
930 |
int64_t value; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
931 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
932 |
value= *(int64_t*) value_ptr(session, var_type, base); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
933 |
|
1
by brian
clean slate |
934 |
return new Item_int(value); |
935 |
}
|
|
936 |
case SHOW_DOUBLE: |
|
937 |
{
|
|
938 |
double value; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
939 |
{
|
940 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
|
941 |
value= *(double*) value_ptr(session, var_type, base); |
|
942 |
}
|
|
943 |
||
1
by brian
clean slate |
944 |
/* 6, as this is for now only used with microseconds */
|
945 |
return new Item_float(value, 6); |
|
946 |
}
|
|
947 |
case SHOW_HA_ROWS: |
|
948 |
{
|
|
949 |
ha_rows value; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
950 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
951 |
value= *(ha_rows*) value_ptr(session, var_type, base); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
952 |
|
151
by Brian Aker
Ulonglong to uint64_t |
953 |
return new Item_int((uint64_t) value); |
1
by brian
clean slate |
954 |
}
|
673.3.17
by Stewart Smith
mostly fix repair test. fix syntax for Drizzle (all tests are MyISAM reliant). |
955 |
case SHOW_SIZE: |
956 |
{
|
|
957 |
size_t value; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
958 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
673.3.17
by Stewart Smith
mostly fix repair test. fix syntax for Drizzle (all tests are MyISAM reliant). |
959 |
value= *(size_t*) value_ptr(session, var_type, base); |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
960 |
|
673.3.17
by Stewart Smith
mostly fix repair test. fix syntax for Drizzle (all tests are MyISAM reliant). |
961 |
return new Item_int((uint64_t) value); |
962 |
}
|
|
1
by brian
clean slate |
963 |
case SHOW_MY_BOOL: |
964 |
{
|
|
205
by Brian Aker
uint32 -> uin32_t |
965 |
int32_t value; |
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
966 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
967 |
value= *(bool*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
968 |
return new Item_int(value,1); |
969 |
}
|
|
970 |
case SHOW_CHAR_PTR: |
|
971 |
{
|
|
972 |
Item *tmp; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
973 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
974 |
char *str= *(char**) value_ptr(session, var_type, base); |
1
by brian
clean slate |
975 |
if (str) |
976 |
{
|
|
482
by Brian Aker
Remove uint. |
977 |
uint32_t length= strlen(str); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
978 |
tmp= new Item_string(session->strmake(str, length), length, |
1
by brian
clean slate |
979 |
system_charset_info, DERIVATION_SYSCONST); |
980 |
}
|
|
981 |
else
|
|
982 |
{
|
|
983 |
tmp= new Item_null(); |
|
984 |
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); |
|
985 |
}
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
986 |
|
1
by brian
clean slate |
987 |
return tmp; |
988 |
}
|
|
989 |
case SHOW_CHAR: |
|
990 |
{
|
|
991 |
Item *tmp; |
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
992 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
993 |
char *str= (char*) value_ptr(session, var_type, base); |
1
by brian
clean slate |
994 |
if (str) |
995 |
tmp= new Item_string(str, strlen(str), |
|
996 |
system_charset_info, DERIVATION_SYSCONST); |
|
997 |
else
|
|
998 |
{
|
|
999 |
tmp= new Item_null(); |
|
1000 |
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST); |
|
1001 |
}
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
1002 |
|
1
by brian
clean slate |
1003 |
return tmp; |
1004 |
}
|
|
1005 |
default: |
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
1006 |
my_error(ER_VAR_CANT_BE_READ, MYF(0), name.c_str()); |
1
by brian
clean slate |
1007 |
}
|
1008 |
return 0; |
|
1009 |
}
|
|
1010 |
||
1011 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1012 |
bool sys_var_session_enum::update(Session *session, set_var *var) |
1
by brian
clean slate |
1013 |
{
|
1014 |
if (var->type == OPT_GLOBAL) |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1015 |
global_system_variables.*offset= var->getInteger(); |
1
by brian
clean slate |
1016 |
else
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1017 |
session->variables.*offset= var->getInteger(); |
1
by brian
clean slate |
1018 |
return 0; |
1019 |
}
|
|
1020 |
||
1021 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1022 |
void sys_var_session_enum::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
1023 |
{
|
1024 |
if (type == OPT_GLOBAL) |
|
621
by Brian Aker
ulong fixes |
1025 |
global_system_variables.*offset= (uint32_t) option_limits->def_value; |
1
by brian
clean slate |
1026 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1027 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1028 |
}
|
1029 |
||
1030 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1031 |
unsigned char *sys_var_session_enum::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
1032 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1033 |
const LEX_STRING *) |
1
by brian
clean slate |
1034 |
{
|
621
by Brian Aker
ulong fixes |
1035 |
uint32_t tmp= ((type == OPT_GLOBAL) ? |
1
by brian
clean slate |
1036 |
global_system_variables.*offset : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1037 |
session->variables.*offset); |
481
by Brian Aker
Remove all of uchar. |
1038 |
return (unsigned char*) enum_names->type_names[tmp]; |
1
by brian
clean slate |
1039 |
}
|
1040 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1041 |
bool sys_var_session_bit::check(Session *session, set_var *var) |
1
by brian
clean slate |
1042 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1043 |
return (check_enum(session, var, &bool_typelib) || |
1044 |
(check_func && (*check_func)(session, var))); |
|
1
by brian
clean slate |
1045 |
}
|
1046 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1047 |
bool sys_var_session_bit::update(Session *session, set_var *var) |
1
by brian
clean slate |
1048 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1049 |
int res= (*update_func)(session, var); |
1
by brian
clean slate |
1050 |
return res; |
1051 |
}
|
|
1052 |
||
1053 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1054 |
unsigned char *sys_var_session_bit::value_ptr(Session *session, sql_var_t, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1055 |
const LEX_STRING *) |
1
by brian
clean slate |
1056 |
{
|
1057 |
/*
|
|
1058 |
If reverse is 0 (default) return 1 if bit is set.
|
|
1059 |
If reverse is 1, return 0 if bit is set
|
|
1060 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1061 |
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ? |
1
by brian
clean slate |
1062 |
!reverse : reverse); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1063 |
return (unsigned char*) &session->sys_var_tmp.bool_value; |
1
by brian
clean slate |
1064 |
}
|
1065 |
||
1066 |
||
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1067 |
bool sys_var_collation_sv::update(Session *session, set_var *var) |
1
by brian
clean slate |
1068 |
{
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
1069 |
const charset_info_st *tmp; |
1
by brian
clean slate |
1070 |
|
1071 |
if (var->value->result_type() == STRING_RESULT) |
|
1072 |
{
|
|
1073 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
1074 |
String str(buff,sizeof(buff), system_charset_info), *res; |
|
1075 |
if (!(res=var->value->val_str(&str))) |
|
1076 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1077 |
boost::throw_exception(invalid_option_value(var->var->getName()) << invalid_value(std::string("NULL"))); |
1
by brian
clean slate |
1078 |
return 1; |
1079 |
}
|
|
862
by Brian Aker
Remove charset directory code. |
1080 |
if (!(tmp=get_charset_by_name(res->c_ptr()))) |
1
by brian
clean slate |
1081 |
{
|
1082 |
my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr()); |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1083 |
boost::throw_exception(invalid_option_value(var->var->getName()) << invalid_value(std::string(res->c_ptr()))); |
1
by brian
clean slate |
1084 |
return 1; |
1085 |
}
|
|
1086 |
}
|
|
1087 |
else // INT_RESULT |
|
1088 |
{
|
|
862
by Brian Aker
Remove charset directory code. |
1089 |
if (!(tmp=get_charset((int) var->value->val_int()))) |
1
by brian
clean slate |
1090 |
{
|
1091 |
char buf[20]; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1092 |
internal::int10_to_str((int) var->value->val_int(), buf, -10); |
1
by brian
clean slate |
1093 |
my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); |
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1094 |
boost::throw_exception(invalid_option_value(var->var->getName()) << invalid_value(boost::lexical_cast<std::string>(var->value->val_int()))); |
1
by brian
clean slate |
1095 |
return 1; |
1096 |
}
|
|
1097 |
}
|
|
1098 |
if (var->type == OPT_GLOBAL) |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1099 |
global_system_variables.*offset= tmp; |
1
by brian
clean slate |
1100 |
else
|
1101 |
{
|
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1102 |
session->variables.*offset= tmp; |
1
by brian
clean slate |
1103 |
}
|
1104 |
return 0; |
|
1105 |
}
|
|
1106 |
||
1107 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1108 |
void sys_var_collation_sv::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
1109 |
{
|
1110 |
if (type == OPT_GLOBAL) |
|
1111 |
global_system_variables.*offset= *global_default; |
|
1112 |
else
|
|
1113 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1114 |
session->variables.*offset= global_system_variables.*offset; |
1
by brian
clean slate |
1115 |
}
|
1116 |
}
|
|
1117 |
||
1118 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1119 |
unsigned char *sys_var_collation_sv::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
1120 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1121 |
const LEX_STRING *) |
1
by brian
clean slate |
1122 |
{
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
1123 |
const charset_info_st *cs= ((type == OPT_GLOBAL) ? |
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1124 |
global_system_variables.*offset : |
1125 |
session->variables.*offset); |
|
481
by Brian Aker
Remove all of uchar. |
1126 |
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL"; |
1
by brian
clean slate |
1127 |
}
|
1128 |
||
1129 |
/****************************************************************************/
|
|
1130 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1131 |
bool sys_var_timestamp::update(Session *session, set_var *var) |
1
by brian
clean slate |
1132 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1133 |
session->set_time(time_t(var->getInteger())); |
1
by brian
clean slate |
1134 |
return 0; |
1135 |
}
|
|
1136 |
||
1137 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1138 |
void sys_var_timestamp::set_default(Session *session, sql_var_t) |
1
by brian
clean slate |
1139 |
{
|
2040.4.4
by Brian Aker
Make more time usage private. |
1140 |
session->resetUserTime(); |
1
by brian
clean slate |
1141 |
}
|
1142 |
||
1143 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1144 |
unsigned char *sys_var_timestamp::value_ptr(Session *session, sql_var_t, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1145 |
const LEX_STRING *) |
1
by brian
clean slate |
1146 |
{
|
2040.4.5
by Brian Aker
Merge in additional updates for time usage. |
1147 |
session->sys_var_tmp.int32_t_value= (int32_t) session->getCurrentTimestampEpoch(); |
1055.2.17
by Jay Pipes
More style cleanups in Session |
1148 |
return (unsigned char*) &session->sys_var_tmp.int32_t_value; |
1
by brian
clean slate |
1149 |
}
|
1150 |
||
1151 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1152 |
bool sys_var_last_insert_id::update(Session *session, set_var *var) |
1
by brian
clean slate |
1153 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1154 |
session->first_successful_insert_id_in_prev_stmt= var->getInteger(); |
1
by brian
clean slate |
1155 |
return 0; |
1156 |
}
|
|
1157 |
||
1158 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1159 |
unsigned char *sys_var_last_insert_id::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
1160 |
sql_var_t, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1161 |
const LEX_STRING *) |
1
by brian
clean slate |
1162 |
{
|
1163 |
/*
|
|
77.1.45
by Monty Taylor
Warning fixes. |
1164 |
this tmp var makes it robust againt change of type of
|
1
by brian
clean slate |
1165 |
read_first_successful_insert_id_in_prev_stmt().
|
1166 |
*/
|
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1167 |
session->sys_var_tmp.uint64_t_value= |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1168 |
session->read_first_successful_insert_id_in_prev_stmt(); |
1169 |
return (unsigned char*) &session->sys_var_tmp.uint64_t_value; |
|
1
by brian
clean slate |
1170 |
}
|
1171 |
||
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1172 |
bool sys_var_session_lc_time_names::update(Session *session, set_var *var) |
1
by brian
clean slate |
1173 |
{
|
1174 |
MY_LOCALE *locale_match; |
|
1175 |
||
1176 |
if (var->value->result_type() == INT_RESULT) |
|
1177 |
{
|
|
895
by Brian Aker
Completion (?) of uint conversion. |
1178 |
if (!(locale_match= my_locale_by_number((uint32_t) var->value->val_int()))) |
1
by brian
clean slate |
1179 |
{
|
2148.5.3
by Brian Aker
Remove hard coded array for numbers (this also fixes a couple of spots where |
1180 |
char buf[DECIMAL_LONGLONG_DIGITS]; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1181 |
internal::int10_to_str((int) var->value->val_int(), buf, -10); |
1
by brian
clean slate |
1182 |
my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf); |
1183 |
return 1; |
|
1184 |
}
|
|
1185 |
}
|
|
1186 |
else // STRING_RESULT |
|
1187 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1188 |
char buff[6]; |
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1189 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res; |
1
by brian
clean slate |
1190 |
if (!(res=var->value->val_str(&str))) |
1191 |
{
|
|
1022.2.38
by Monty Taylor
Changed name to std::string. |
1192 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.c_str(), "NULL"); |
1
by brian
clean slate |
1193 |
return 1; |
1194 |
}
|
|
1195 |
const char *locale_str= res->c_ptr(); |
|
1196 |
if (!(locale_match= my_locale_by_name(locale_str))) |
|
1197 |
{
|
|
1198 |
my_printf_error(ER_UNKNOWN_ERROR, |
|
1199 |
"Unknown locale: '%s'", MYF(0), locale_str); |
|
1200 |
return 1; |
|
1201 |
}
|
|
1202 |
}
|
|
1203 |
||
1204 |
if (var->type == OPT_GLOBAL) |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1205 |
global_system_variables.lc_time_names= locale_match; |
1
by brian
clean slate |
1206 |
else
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1207 |
session->variables.lc_time_names= locale_match; |
1
by brian
clean slate |
1208 |
return 0; |
1209 |
}
|
|
1210 |
||
1211 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1212 |
unsigned char *sys_var_session_lc_time_names::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
1213 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1214 |
const LEX_STRING *) |
1
by brian
clean slate |
1215 |
{
|
1216 |
return type == OPT_GLOBAL ? |
|
481
by Brian Aker
Remove all of uchar. |
1217 |
(unsigned char *) global_system_variables.lc_time_names->name : |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1218 |
(unsigned char *) session->variables.lc_time_names->name; |
1
by brian
clean slate |
1219 |
}
|
1220 |
||
1221 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1222 |
void sys_var_session_lc_time_names::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
1223 |
{
|
1224 |
if (type == OPT_GLOBAL) |
|
1225 |
global_system_variables.lc_time_names= my_default_lc_time_names; |
|
1226 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1227 |
session->variables.lc_time_names= global_system_variables.lc_time_names; |
1
by brian
clean slate |
1228 |
}
|
1229 |
||
1230 |
/*
|
|
1231 |
Handling of microseoncds given as seconds.part_seconds
|
|
1232 |
||
1233 |
NOTES
|
|
1234 |
The argument to long query time is in seconds in decimal
|
|
151
by Brian Aker
Ulonglong to uint64_t |
1235 |
which is converted to uint64_t integer holding microseconds for storage.
|
1
by brian
clean slate |
1236 |
This is used for handling long_query_time
|
1237 |
*/
|
|
1238 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1239 |
bool sys_var_microseconds::update(Session *session, set_var *var) |
1
by brian
clean slate |
1240 |
{
|
1241 |
double num= var->value->val_real(); |
|
152
by Brian Aker
longlong replacement |
1242 |
int64_t microseconds; |
1
by brian
clean slate |
1243 |
if (num > (double) option_limits->max_value) |
1244 |
num= (double) option_limits->max_value; |
|
1245 |
if (num < (double) option_limits->min_value) |
|
1246 |
num= (double) option_limits->min_value; |
|
152
by Brian Aker
longlong replacement |
1247 |
microseconds= (int64_t) (num * 1000000.0 + 0.5); |
1
by brian
clean slate |
1248 |
if (var->type == OPT_GLOBAL) |
1249 |
{
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
1250 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
1
by brian
clean slate |
1251 |
(global_system_variables.*offset)= microseconds; |
1252 |
}
|
|
1253 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1254 |
session->variables.*offset= microseconds; |
1
by brian
clean slate |
1255 |
return 0; |
1256 |
}
|
|
1257 |
||
1258 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1259 |
void sys_var_microseconds::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
1260 |
{
|
152
by Brian Aker
longlong replacement |
1261 |
int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0); |
1
by brian
clean slate |
1262 |
if (type == OPT_GLOBAL) |
1263 |
{
|
|
2114.3.1
by Brian Aker
Move variable lock into the catalog that the variables belong too. |
1264 |
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock()); |
1
by brian
clean slate |
1265 |
global_system_variables.*offset= microseconds; |
1266 |
}
|
|
1267 |
else
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1268 |
session->variables.*offset= microseconds; |
1
by brian
clean slate |
1269 |
}
|
1270 |
||
1271 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1272 |
Functions to update session->options bits
|
1
by brian
clean slate |
1273 |
*/
|
1274 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1275 |
static bool set_option_bit(Session *session, set_var *var) |
1
by brian
clean slate |
1276 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1277 |
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var); |
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1278 |
if ((var->getInteger() != 0) == sys_var->reverse) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1279 |
session->options&= ~sys_var->bit_flag; |
1
by brian
clean slate |
1280 |
else
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1281 |
session->options|= sys_var->bit_flag; |
1
by brian
clean slate |
1282 |
return 0; |
1283 |
}
|
|
1284 |
||
1285 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1286 |
static bool set_option_autocommit(Session *session, set_var *var) |
1
by brian
clean slate |
1287 |
{
|
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1288 |
bool success= true; |
1
by brian
clean slate |
1289 |
/* The test is negative as the flag we use is NOT autocommit */
|
1290 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1291 |
uint64_t org_options= session->options; |
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1292 |
uint64_t new_options= session->options; |
1
by brian
clean slate |
1293 |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1294 |
if (var->getInteger() != 0) |
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1295 |
new_options&= ~((sys_var_session_bit*) var->var)->bit_flag; |
1
by brian
clean slate |
1296 |
else
|
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1297 |
new_options|= ((sys_var_session_bit*) var->var)->bit_flag; |
1
by brian
clean slate |
1298 |
|
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1299 |
if ((org_options ^ new_options) & OPTION_NOT_AUTOCOMMIT) |
1
by brian
clean slate |
1300 |
{
|
1301 |
if ((org_options & OPTION_NOT_AUTOCOMMIT)) |
|
1302 |
{
|
|
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1303 |
success= session->endActiveTransaction(); |
1
by brian
clean slate |
1304 |
/* We changed to auto_commit mode */
|
1172.1.2
by Brian Aker
Remove worthless call (ok... for not current replication system). |
1305 |
session->options&= ~(uint64_t) (OPTION_BEGIN); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1306 |
session->server_status|= SERVER_STATUS_AUTOCOMMIT; |
1
by brian
clean slate |
1307 |
}
|
1308 |
else
|
|
1309 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1310 |
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT; |
1
by brian
clean slate |
1311 |
}
|
1312 |
}
|
|
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1313 |
|
1890.2.53
by Stewart Smith
merge trunk |
1314 |
if (var->getInteger() != 0) |
1890.2.5
by Stewart Smith
SET AUTOCOMMIT=1 was not completely performing a COMMIT |
1315 |
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag; |
1316 |
else
|
|
1317 |
session->options|= ((sys_var_session_bit*) var->var)->bit_flag; |
|
1318 |
||
1319 |
if (not success) |
|
1320 |
return true; |
|
1321 |
||
1
by brian
clean slate |
1322 |
return 0; |
1323 |
}
|
|
1324 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1325 |
static int check_pseudo_thread_id(Session *, set_var *var) |
1
by brian
clean slate |
1326 |
{
|
2070.2.1
by Monty Taylor
First step in getting that anonymous union out of set_var. |
1327 |
var->updateValue(); |
1
by brian
clean slate |
1328 |
return 0; |
1329 |
}
|
|
1330 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1331 |
static unsigned char *get_warning_count(Session *session) |
1
by brian
clean slate |
1332 |
{
|
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. |
1333 |
session->sys_var_tmp.uint32_t_value= |
626
by Brian Aker
More of the same (ulong/64) |
1334 |
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] + |
1335 |
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] + |
|
1336 |
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. |
1337 |
return (unsigned char*) &session->sys_var_tmp.uint32_t_value; |
1
by brian
clean slate |
1338 |
}
|
1339 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1340 |
static unsigned char *get_error_count(Session *session) |
1
by brian
clean slate |
1341 |
{
|
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. |
1342 |
session->sys_var_tmp.uint32_t_value= |
626
by Brian Aker
More of the same (ulong/64) |
1343 |
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. |
1344 |
return (unsigned char*) &session->sys_var_tmp.uint32_t_value; |
1
by brian
clean slate |
1345 |
}
|
1346 |
||
1347 |
||
1348 |
/**
|
|
1349 |
Get the tmpdir that was specified or chosen by default.
|
|
1350 |
||
1351 |
This is necessary because if the user does not specify a temporary
|
|
1352 |
directory via the command line, one is chosen based on the environment
|
|
575.4.3
by ysano
Rename mysql to drizzle. |
1353 |
or system defaults. But we can't just always use drizzle_tmpdir, because
|
1
by brian
clean slate |
1354 |
that is actually a call to my_tmpdir() which cycles among possible
|
1355 |
temporary directories.
|
|
1356 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1357 |
@param session thread handle
|
1
by brian
clean slate |
1358 |
|
1359 |
@retval
|
|
1360 |
ptr pointer to NUL-terminated string
|
|
1361 |
*/
|
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1362 |
static unsigned char *get_tmpdir(Session *) |
1
by brian
clean slate |
1363 |
{
|
1556.1.1
by Brian Aker
Updates for moving temporary directory. |
1364 |
assert(drizzle_tmpdir.size()); |
1365 |
return (unsigned char*)drizzle_tmpdir.c_str(); |
|
1
by brian
clean slate |
1366 |
}
|
1367 |
||
1368 |
/****************************************************************************
|
|
1369 |
Main handling of variables:
|
|
1370 |
- Initialisation
|
|
1371 |
- Searching during parsing
|
|
1372 |
- Update loop
|
|
1373 |
****************************************************************************/
|
|
1374 |
||
1375 |
/**
|
|
1376 |
Find variable name in option my_getopt structure used for
|
|
1377 |
command line args.
|
|
1378 |
||
1379 |
@param opt option structure array to search in
|
|
1380 |
@param name variable name
|
|
1381 |
||
1382 |
@retval
|
|
1383 |
0 Error
|
|
1384 |
@retval
|
|
1385 |
ptr pointer to option structure
|
|
1386 |
*/
|
|
1387 |
||
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1388 |
static struct option *find_option(struct option *opt, const char *name) |
1
by brian
clean slate |
1389 |
{
|
482
by Brian Aker
Remove uint. |
1390 |
uint32_t length=strlen(name); |
1
by brian
clean slate |
1391 |
for (; opt->name; opt++) |
1392 |
{
|
|
1393 |
if (!getopt_compare_strings(opt->name, name, length) && |
|
1394 |
!opt->name[length]) |
|
1395 |
{
|
|
1396 |
/*
|
|
1397 |
Only accept the option if one can set values through it.
|
|
1398 |
If not, there is no default value or limits in the option.
|
|
1399 |
*/
|
|
1400 |
return (opt->value) ? opt : 0; |
|
1401 |
}
|
|
1402 |
}
|
|
1403 |
return 0; |
|
1404 |
}
|
|
1405 |
||
1406 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1407 |
|
1408 |
||
1409 |
||
1
by brian
clean slate |
1410 |
/*
|
1411 |
Constructs an array of system variables for display to the user.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1412 |
|
1
by brian
clean slate |
1413 |
SYNOPSIS
|
1414 |
enumerate_sys_vars()
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1415 |
session current thread
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1416 |
|
1
by brian
clean slate |
1417 |
RETURN VALUES
|
1273.13.73
by Brian Aker
Remove typedef and drop some dead code. |
1418 |
pointer Array of drizzle_show_var elements for display
|
1
by brian
clean slate |
1419 |
NULL FAILURE
|
1420 |
*/
|
|
1421 |
||
1813.2.8
by Monty Taylor
Removed the fixed_vars. |
1422 |
drizzle_show_var* enumerate_sys_vars(Session *session) |
1
by brian
clean slate |
1423 |
{
|
1813.2.8
by Monty Taylor
Removed the fixed_vars. |
1424 |
int size= sizeof(drizzle_show_var) * (system_variable_map.size() + 1); |
2148.7.8
by Brian Aker
Remove bits from Session where was providing a service directly. |
1425 |
drizzle_show_var *result= (drizzle_show_var*) session->getMemRoot()->allocate(size); |
1
by brian
clean slate |
1426 |
|
1427 |
if (result) |
|
1428 |
{
|
|
1813.2.8
by Monty Taylor
Removed the fixed_vars. |
1429 |
drizzle_show_var *show= result; |
2246.4.1
by Olaf van der Spek
Use BOOST_FOREACH |
1430 |
BOOST_FOREACH(SystemVariableMap::const_reference iter, system_variable_map) |
1
by brian
clean slate |
1431 |
{
|
2246.4.1
by Olaf van der Spek
Use BOOST_FOREACH |
1432 |
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. |
1433 |
show->name= var->getName().c_str(); |
1
by brian
clean slate |
1434 |
show->value= (char*) var; |
1435 |
show->type= SHOW_SYS; |
|
1813.2.8
by Monty Taylor
Removed the fixed_vars. |
1436 |
++show; |
1
by brian
clean slate |
1437 |
}
|
1438 |
||
1439 |
/* make last element empty */
|
|
1273.13.73
by Brian Aker
Remove typedef and drop some dead code. |
1440 |
memset(show, 0, sizeof(drizzle_show_var)); |
1
by brian
clean slate |
1441 |
}
|
1442 |
return result; |
|
1443 |
}
|
|
1444 |
||
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1445 |
void add_sys_var_to_list(sys_var *var) |
1446 |
{
|
|
1447 |
string lower_name(var->getName()); |
|
2246.4.1
by Olaf van der Spek
Use BOOST_FOREACH |
1448 |
transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1449 |
|
1450 |
/* this fails if there is a conflicting variable name. */
|
|
2192.5.2
by Olaf van der Spek
Use map::count |
1451 |
if (system_variable_map.count(lower_name)) |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1452 |
{
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
1453 |
errmsg_printf(error::ERROR, _("Variable named %s already exists!\n"), |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1454 |
var->getName().c_str()); |
1455 |
throw exception(); |
|
1456 |
}
|
|
1457 |
||
1458 |
pair<SystemVariableMap::iterator, bool> ret= |
|
1459 |
system_variable_map.insert(make_pair(lower_name, var)); |
|
1460 |
if (ret.second == false) |
|
1461 |
{
|
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
1462 |
errmsg_printf(error::ERROR, _("Could not add Variable: %s\n"), |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1463 |
var->getName().c_str()); |
1464 |
throw exception(); |
|
1465 |
}
|
|
1466 |
}
|
|
1467 |
||
1468 |
void add_sys_var_to_list(sys_var *var, struct option *long_options) |
|
1469 |
{
|
|
1470 |
add_sys_var_to_list(var); |
|
1471 |
var->setOptionLimits(find_option(long_options, var->getName().c_str())); |
|
1472 |
}
|
|
1473 |
||
1
by brian
clean slate |
1474 |
/*
|
1475 |
Initialize the system variables
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1476 |
|
1
by brian
clean slate |
1477 |
SYNOPSIS
|
1878.3.1
by Monty Taylor
Split set_var.* into sys_var.* and set_var.* |
1478 |
sys_var_init()
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1479 |
|
1
by brian
clean slate |
1480 |
RETURN VALUES
|
1481 |
0 SUCCESS
|
|
1482 |
otherwise FAILURE
|
|
1483 |
*/
|
|
1484 |
||
1878.3.1
by Monty Taylor
Split set_var.* into sys_var.* and set_var.* |
1485 |
int sys_var_init() |
1
by brian
clean slate |
1486 |
{
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1487 |
try
|
1488 |
{
|
|
1489 |
add_sys_var_to_list(&sys_auto_increment_increment, my_long_options); |
|
1490 |
add_sys_var_to_list(&sys_auto_increment_offset, my_long_options); |
|
1491 |
add_sys_var_to_list(&sys_autocommit, my_long_options); |
|
1492 |
add_sys_var_to_list(&sys_back_log, my_long_options); |
|
1493 |
add_sys_var_to_list(&sys_basedir, my_long_options); |
|
1494 |
add_sys_var_to_list(&sys_big_selects, my_long_options); |
|
2183.1.2
by Monty Taylor
A slew of tiny meaningless changes. |
1495 |
add_sys_var_to_list(&sys_branch, my_long_options); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1496 |
add_sys_var_to_list(&sys_buffer_results, my_long_options); |
1497 |
add_sys_var_to_list(&sys_bulk_insert_buff_size, my_long_options); |
|
1498 |
add_sys_var_to_list(&sys_collation_server, my_long_options); |
|
1499 |
add_sys_var_to_list(&sys_completion_type, my_long_options); |
|
1500 |
add_sys_var_to_list(&sys_datadir, my_long_options); |
|
1501 |
add_sys_var_to_list(&sys_div_precincrement, my_long_options); |
|
1502 |
add_sys_var_to_list(&sys_error_count, my_long_options); |
|
1503 |
add_sys_var_to_list(&sys_foreign_key_checks, my_long_options); |
|
1504 |
add_sys_var_to_list(&sys_group_concat_max_len, my_long_options); |
|
1505 |
add_sys_var_to_list(&sys_hostname, my_long_options); |
|
1506 |
add_sys_var_to_list(&sys_identity, my_long_options); |
|
1507 |
add_sys_var_to_list(&sys_join_buffer_size, my_long_options); |
|
1508 |
add_sys_var_to_list(&sys_last_insert_id, my_long_options); |
|
1509 |
add_sys_var_to_list(&sys_lc_time_names, my_long_options); |
|
1510 |
add_sys_var_to_list(&sys_max_allowed_packet, my_long_options); |
|
1511 |
add_sys_var_to_list(&sys_max_error_count, my_long_options); |
|
1512 |
add_sys_var_to_list(&sys_max_heap_table_size, my_long_options); |
|
1513 |
add_sys_var_to_list(&sys_max_join_size, my_long_options); |
|
1514 |
add_sys_var_to_list(&sys_max_length_for_sort_data, my_long_options); |
|
1515 |
add_sys_var_to_list(&sys_max_seeks_for_key, my_long_options); |
|
1516 |
add_sys_var_to_list(&sys_max_sort_length, my_long_options); |
|
1517 |
add_sys_var_to_list(&sys_max_write_lock_count, my_long_options); |
|
1518 |
add_sys_var_to_list(&sys_min_examined_row_limit, my_long_options); |
|
1519 |
add_sys_var_to_list(&sys_optimizer_prune_level, my_long_options); |
|
1520 |
add_sys_var_to_list(&sys_optimizer_search_depth, my_long_options); |
|
1521 |
add_sys_var_to_list(&sys_pid_file, my_long_options); |
|
1522 |
add_sys_var_to_list(&sys_plugin_dir, my_long_options); |
|
1523 |
add_sys_var_to_list(&sys_preload_buff_size, my_long_options); |
|
1524 |
add_sys_var_to_list(&sys_pseudo_thread_id, my_long_options); |
|
1525 |
add_sys_var_to_list(&sys_query_alloc_block_size, my_long_options); |
|
1526 |
add_sys_var_to_list(&sys_query_prealloc_size, my_long_options); |
|
1527 |
add_sys_var_to_list(&sys_range_alloc_block_size, my_long_options); |
|
1528 |
add_sys_var_to_list(&sys_read_buff_size, my_long_options); |
|
1529 |
add_sys_var_to_list(&sys_read_rnd_buff_size, my_long_options); |
|
2183.1.2
by Monty Taylor
A slew of tiny meaningless changes. |
1530 |
add_sys_var_to_list(&sys_release_id, my_long_options); |
1938.3.1
by David Shrewsbury
Add --replicate-query option. |
1531 |
add_sys_var_to_list(&sys_replicate_query, my_long_options); |
2183.1.2
by Monty Taylor
A slew of tiny meaningless changes. |
1532 |
add_sys_var_to_list(&sys_revid, my_long_options); |
1533 |
add_sys_var_to_list(&sys_revno, my_long_options); |
|
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1534 |
add_sys_var_to_list(&sys_scheduler, my_long_options); |
1535 |
add_sys_var_to_list(&sys_secure_file_priv, my_long_options); |
|
1536 |
add_sys_var_to_list(&sys_select_limit, my_long_options); |
|
1537 |
add_sys_var_to_list(&sys_server_id, my_long_options); |
|
1538 |
add_sys_var_to_list(&sys_sort_buffer, my_long_options); |
|
1539 |
add_sys_var_to_list(&sys_sql_notes, my_long_options); |
|
1540 |
add_sys_var_to_list(&sys_sql_warnings, my_long_options); |
|
1541 |
add_sys_var_to_list(&sys_storage_engine, my_long_options); |
|
1542 |
add_sys_var_to_list(&sys_table_cache_size, my_long_options); |
|
1543 |
add_sys_var_to_list(&sys_table_def_size, my_long_options); |
|
1544 |
add_sys_var_to_list(&sys_table_lock_wait_timeout, my_long_options); |
|
1545 |
add_sys_var_to_list(&sys_thread_stack_size, my_long_options); |
|
1546 |
add_sys_var_to_list(&sys_timed_mutexes, my_long_options); |
|
1547 |
add_sys_var_to_list(&sys_timestamp, my_long_options); |
|
1548 |
add_sys_var_to_list(&sys_tmp_table_size, my_long_options); |
|
1549 |
add_sys_var_to_list(&sys_tmpdir, my_long_options); |
|
1550 |
add_sys_var_to_list(&sys_transaction_message_threshold, my_long_options); |
|
1551 |
add_sys_var_to_list(&sys_tx_isolation, my_long_options); |
|
1552 |
add_sys_var_to_list(&sys_unique_checks, my_long_options); |
|
1553 |
add_sys_var_to_list(&sys_version, my_long_options); |
|
1554 |
add_sys_var_to_list(&sys_version_comment, my_long_options); |
|
1555 |
add_sys_var_to_list(&sys_version_compile_machine, my_long_options); |
|
1556 |
add_sys_var_to_list(&sys_version_compile_os, my_long_options); |
|
1557 |
add_sys_var_to_list(&sys_version_compile_vendor, my_long_options); |
|
1558 |
add_sys_var_to_list(&sys_warning_count, my_long_options); |
|
1559 |
}
|
|
1966.3.1
by Monty Taylor
Use std::exception instead of catch(...) |
1560 |
catch (std::exception&) |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1561 |
{
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
1562 |
errmsg_printf(error::ERROR, _("Failed to initialize system variables")); |
1851.1.1
by Monty Taylor
Removed sys_var_chain. |
1563 |
return(1); |
1564 |
}
|
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1565 |
return(0); |
1
by brian
clean slate |
1566 |
}
|
1567 |
||
1568 |
||
1569 |
/**
|
|
1570 |
Find a user set-table variable.
|
|
1571 |
||
2040.6.2
by Monty Taylor
Made find_sys_var take a const std::string& instead. |
1572 |
@param name Name of system variable to find
|
1
by brian
clean slate |
1573 |
|
1574 |
@retval
|
|
1575 |
pointer pointer to variable definitions
|
|
1576 |
@retval
|
|
1577 |
0 Unknown variable (error message is given)
|
|
1578 |
*/
|
|
1579 |
||
2040.6.3
by Monty Taylor
Removed unused no_error bool param. |
1580 |
sys_var *find_sys_var(const std::string &name) |
1
by brian
clean slate |
1581 |
{
|
2040.6.2
by Monty Taylor
Made find_sys_var take a const std::string& instead. |
1582 |
string lower_name(name); |
2246.4.1
by Olaf van der Spek
Use BOOST_FOREACH |
1583 |
transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); |
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1584 |
|
1585 |
sys_var *result= NULL; |
|
1586 |
||
2192.5.8
by Olaf van der Spek
Use ptr instead of i |
1587 |
if (SystemVariableMap::mapped_type* ptr= find_ptr(system_variable_map, lower_name)) |
1588 |
result= *ptr; |
|
1228.3.1
by Monty Taylor
Removed NameMap. Also remove the aliases from the plugin, since we can just |
1589 |
|
1022.2.37
by Monty Taylor
Moved more tolower calls to setup rather than during runtime. |
1590 |
if (result == NULL) |
896.1.1
by Monty Taylor
Actually return NULL from intern_find_sys_var on error thank you. |
1591 |
{
|
2040.6.3
by Monty Taylor
Removed unused no_error bool param. |
1592 |
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), name.c_str()); |
1593 |
return NULL; |
|
896.1.1
by Monty Taylor
Actually return NULL from intern_find_sys_var on error thank you. |
1594 |
}
|
1
by brian
clean slate |
1595 |
|
1022.2.37
by Monty Taylor
Moved more tolower calls to setup rather than during runtime. |
1596 |
return result; |
1
by brian
clean slate |
1597 |
}
|
1598 |
||
1599 |
||
1600 |
/****************************************************************************
|
|
1601 |
Functions to handle table_type
|
|
1602 |
****************************************************************************/
|
|
1603 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1604 |
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session, |
1273.13.24
by Brian Aker
Updating style, simplified code. |
1605 |
sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1606 |
const LEX_STRING *) |
1
by brian
clean slate |
1607 |
{
|
481
by Brian Aker
Remove all of uchar. |
1608 |
unsigned char* result; |
968.2.29
by Monty Taylor
First steps towards new plugin reg. |
1609 |
string engine_name; |
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
1610 |
plugin::StorageEngine *engine= session->variables.*offset; |
1
by brian
clean slate |
1611 |
if (type == OPT_GLOBAL) |
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1612 |
engine= global_system_variables.*offset; |
971.1.14
by Monty Taylor
Slurp around strings rather than char* for storage engine name. |
1613 |
engine_name= engine->getName(); |
968.2.29
by Monty Taylor
First steps towards new plugin reg. |
1614 |
result= (unsigned char *) session->strmake(engine_name.c_str(), |
1615 |
engine_name.size()); |
|
1
by brian
clean slate |
1616 |
return result; |
1617 |
}
|
|
1618 |
||
1619 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1620 |
void sys_var_session_storage_engine::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
1621 |
{
|
2253.1.1
by Andrew Hutchings
Fix Drizzle to compile in GCC 4.6 (which fires warnings and therefore errors if a variable is set and not read) |
1622 |
plugin::StorageEngine *new_value, **value; |
1
by brian
clean slate |
1623 |
if (type == OPT_GLOBAL) |
1624 |
{
|
|
1625 |
value= &(global_system_variables.*offset); |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1626 |
new_value= myisam_engine; |
1
by brian
clean slate |
1627 |
}
|
1628 |
else
|
|
1629 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1630 |
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. |
1631 |
new_value= global_system_variables.*offset; |
1
by brian
clean slate |
1632 |
}
|
51.1.46
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1633 |
assert(new_value); |
1
by brian
clean slate |
1634 |
*value= new_value; |
1635 |
}
|
|
1636 |
||
1637 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1638 |
bool sys_var_session_storage_engine::update(Session *session, set_var *var) |
1
by brian
clean slate |
1639 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1640 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
1641 |
const char *name_value; |
|
1642 |
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res; |
|
1643 |
||
1644 |
plugin::StorageEngine *tmp= NULL; |
|
1645 |
plugin::StorageEngine **value= NULL; |
|
1646 |
||
1647 |
if (var->value->result_type() == STRING_RESULT) |
|
1648 |
{
|
|
1649 |
res= var->value->val_str(&str); |
|
1650 |
if (res == NULL || res->ptr() == NULL) |
|
1651 |
{
|
|
1652 |
name_value= "NULL"; |
|
1653 |
goto err; |
|
1654 |
}
|
|
1655 |
else
|
|
1656 |
{
|
|
1657 |
const std::string engine_name(res->ptr()); |
|
1658 |
tmp= plugin::StorageEngine::findByName(*session, engine_name); |
|
1659 |
if (tmp == NULL) |
|
1660 |
{
|
|
1661 |
name_value= res->c_ptr(); |
|
1662 |
goto err; |
|
1663 |
}
|
|
1664 |
}
|
|
1665 |
}
|
|
1666 |
else
|
|
1667 |
{
|
|
1668 |
name_value= "unknown"; |
|
1669 |
}
|
|
1670 |
||
1671 |
value= &(global_system_variables.*offset); |
|
1
by brian
clean slate |
1672 |
if (var->type != OPT_GLOBAL) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1673 |
value= &(session->variables.*offset); |
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1674 |
if (*value != tmp) |
1
by brian
clean slate |
1675 |
{
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1676 |
*value= tmp; |
1
by brian
clean slate |
1677 |
}
|
1678 |
return 0; |
|
2070.2.2
by Monty Taylor
Removed some guts from set_var. |
1679 |
err: |
1680 |
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name_value); |
|
1681 |
return 1; |
|
1
by brian
clean slate |
1682 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1683 |
|
1684 |
} /* namespace drizzled */ |