46
46
#include "config.h"
47
47
#include "drizzled/option.h"
48
#include <drizzled/error.h>
49
#include <drizzled/gettext.h>
50
#include <drizzled/tztime.h>
51
#include <drizzled/data_home.h>
52
#include <drizzled/set_var.h>
53
#include <drizzled/session.h>
54
#include <drizzled/sql_base.h>
55
#include <drizzled/lock.h>
56
#include <drizzled/item/uint.h>
57
#include <drizzled/item/null.h>
58
#include <drizzled/item/float.h>
59
#include <drizzled/plugin.h>
48
#include "drizzled/error.h"
49
#include "drizzled/gettext.h"
50
#include "drizzled/tztime.h"
51
#include "drizzled/data_home.h"
52
#include "drizzled/set_var.h"
53
#include "drizzled/session.h"
54
#include "drizzled/sql_base.h"
55
#include "drizzled/lock.h"
56
#include "drizzled/item/uint.h"
57
#include "drizzled/item/null.h"
58
#include "drizzled/item/float.h"
59
#include "drizzled/item/string.h"
60
#include "drizzled/plugin.h"
60
61
#include "drizzled/version.h"
61
62
#include "drizzled/strfunc.h"
62
63
#include "drizzled/internal/m_string.h"
143
144
static sys_var_constrained_value<uint32_t> sys_back_log("back_log", back_log);
145
146
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size",
146
&system_variables::bulk_insert_buff_size);
147
&drizzle_system_variables::bulk_insert_buff_size);
147
148
static sys_var_session_uint32_t sys_completion_type("completion_type",
148
&system_variables::completion_type,
149
&drizzle_system_variables::completion_type,
149
150
check_completion_type,
150
151
fix_completion_type);
151
152
static sys_var_collation_sv
152
sys_collation_server("collation_server", &system_variables::collation_server, &default_charset_info);
153
sys_collation_server("collation_server", &drizzle_system_variables::collation_server, &default_charset_info);
153
154
static sys_var_fs_path sys_datadir("datadir", getDataHome());
155
156
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size",
156
&system_variables::join_buff_size);
157
&drizzle_system_variables::join_buff_size);
157
158
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet",
158
&system_variables::max_allowed_packet);
159
&drizzle_system_variables::max_allowed_packet);
159
160
static sys_var_uint64_t_ptr sys_max_connect_errors("max_connect_errors",
160
161
&max_connect_errors);
161
162
static sys_var_session_uint64_t sys_max_error_count("max_error_count",
162
&system_variables::max_error_count);
163
&drizzle_system_variables::max_error_count);
163
164
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size",
164
&system_variables::max_heap_table_size);
165
&drizzle_system_variables::max_heap_table_size);
165
166
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id",
166
&system_variables::pseudo_thread_id,
167
&drizzle_system_variables::pseudo_thread_id,
167
168
0, check_pseudo_thread_id);
168
169
static sys_var_session_ha_rows sys_max_join_size("max_join_size",
169
&system_variables::max_join_size,
170
&drizzle_system_variables::max_join_size,
170
171
fix_max_join_size);
171
172
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key",
172
&system_variables::max_seeks_for_key);
173
&drizzle_system_variables::max_seeks_for_key);
173
174
static sys_var_session_uint64_t sys_max_length_for_sort_data("max_length_for_sort_data",
174
&system_variables::max_length_for_sort_data);
175
&drizzle_system_variables::max_length_for_sort_data);
175
176
static sys_var_session_size_t sys_max_sort_length("max_sort_length",
176
&system_variables::max_sort_length);
177
&drizzle_system_variables::max_sort_length);
177
178
static sys_var_uint64_t_ptr sys_max_write_lock_count("max_write_lock_count",
178
179
&max_write_lock_count);
179
180
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit",
180
&system_variables::min_examined_row_limit);
181
&drizzle_system_variables::min_examined_row_limit);
182
183
/* these two cannot be static */
183
184
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level",
184
&system_variables::optimizer_prune_level);
185
&drizzle_system_variables::optimizer_prune_level);
185
186
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth",
186
&system_variables::optimizer_search_depth);
187
&drizzle_system_variables::optimizer_search_depth);
188
189
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size",
189
&system_variables::preload_buff_size);
190
&drizzle_system_variables::preload_buff_size);
190
191
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size",
191
&system_variables::read_buff_size);
192
&drizzle_system_variables::read_buff_size);
192
193
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size",
193
&system_variables::read_rnd_buff_size);
194
&drizzle_system_variables::read_rnd_buff_size);
194
195
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment",
195
&system_variables::div_precincrement);
196
&drizzle_system_variables::div_precincrement);
197
198
static sys_var_session_size_t sys_range_alloc_block_size("range_alloc_block_size",
198
&system_variables::range_alloc_block_size);
199
&drizzle_system_variables::range_alloc_block_size);
199
200
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size",
200
&system_variables::query_alloc_block_size,
201
&drizzle_system_variables::query_alloc_block_size,
201
202
NULL, fix_session_mem_root);
202
203
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size",
203
&system_variables::query_prealloc_size,
204
&drizzle_system_variables::query_prealloc_size,
204
205
NULL, fix_session_mem_root);
205
206
static sys_var_readonly sys_tmpdir("tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
1690
Execute update of all variables.
1692
First run a check of all variables that all updates will go ok.
1693
If yes, then execute all updates, returning an error if any one failed.
1695
This should ensure that in all normal cases none all or variables are
1698
@param Session Thread id
1699
@param var_list List of variables to update
1704
1 ERROR, message sent (normally no variables was updated)
1706
-1 ERROR, message not sent
1709
int sql_set_variables(Session *session, List<set_var_base> *var_list)
1712
List_iterator_fast<set_var_base> it(*var_list);
1717
if ((error= var->check(session)))
1720
if (!(error= test(session->is_error())))
1724
error|= var->update(session); // Returns 0, -1 or 1
1728
free_underlaid_joins(session, &session->lex->select_lex);
1733
/*****************************************************************************
1734
Functions to handle SET mysql_internal_variable=const_expr
1735
*****************************************************************************/
1737
int set_var::check(Session *session)
1739
if (var->is_readonly())
1741
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->getName().c_str(), "read only");
1744
if (var->check_type(type))
1746
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
1747
my_error(err, MYF(0), var->getName().c_str());
1750
/* value is a NULL pointer if we are using SET ... = DEFAULT */
1753
if (var->check_default(type))
1755
my_error(ER_NO_DEFAULT, MYF(0), var->getName().c_str());
1761
if ((!value->fixed &&
1762
value->fix_fields(session, &value)) || value->check_cols(1))
1764
if (var->check_update_type(value->result_type()))
1766
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->getName().c_str());
1769
return var->check(session, this) ? -1 : 0;
1775
@param session thread handler
1776
@returns 0|1 ok or ERROR
1778
@note ERROR can be only due to abnormal operations involving
1779
the server's execution evironment such as
1780
out of memory, hard disk failure or the computer blows up.
1781
Consider set_var::check() method if there is a need to return
1782
an error due to logics.
1784
int set_var::update(Session *session)
1787
var->set_default(session, type);
1788
else if (var->update(session, this))
1789
return -1; // should never happen
1790
if (var->getAfterUpdateTrigger())
1791
(*var->getAfterUpdateTrigger())(session, type);
1795
/*****************************************************************************
1796
Functions to handle SET @user_variable=const_expr
1797
*****************************************************************************/
1799
int set_var_user::check(Session *session)
1802
Item_func_set_user_var can't substitute something else on its place =>
1803
0 can be passed as last argument (reference on item)
1805
return (user_var_item->fix_fields(session, (Item**) 0) ||
1806
user_var_item->check(0)) ? -1 : 0;
1810
int set_var_user::update(Session *)
1812
if (user_var_item->update())
1814
/* Give an error if it's not given already */
1815
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0));
1821
1690
/****************************************************************************
1822
1691
Functions to handle table_type
1823
1692
****************************************************************************/