56
51
#include <drizzled/item/uint.h>
57
52
#include <drizzled/item/null.h>
58
53
#include <drizzled/item/float.h>
54
#include <drizzled/item/string.h>
59
55
#include <drizzled/plugin.h>
60
#include "drizzled/version.h"
61
#include "drizzled/strfunc.h"
62
#include "drizzled/internal/m_string.h"
63
#include "drizzled/pthread_globals.h"
64
#include "drizzled/charset.h"
65
#include "drizzled/transaction_services.h"
56
#include <drizzled/version.h>
57
#include <drizzled/strfunc.h>
58
#include <drizzled/internal/m_string.h>
59
#include <drizzled/pthread_globals.h>
60
#include <drizzled/charset.h>
61
#include <drizzled/transaction_services.h>
62
#include <drizzled/constrained_value.h>
63
#include <drizzled/visibility.h>
64
#include <drizzled/typelib.h>
65
#include <drizzled/plugin/storage_engine.h>
140
143
static sys_var_size_t_ptr sys_thread_stack_size("thread_stack",
141
144
&my_thread_stack_size);
142
static sys_var_uint32_t_ptr sys_back_log("back_log", &back_log);
145
static sys_var_constrained_value_readonly<uint32_t> sys_back_log("back_log", back_log);
144
147
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size",
145
&system_variables::bulk_insert_buff_size);
148
&drizzle_system_variables::bulk_insert_buff_size);
146
149
static sys_var_session_uint32_t sys_completion_type("completion_type",
147
&system_variables::completion_type,
150
&drizzle_system_variables::completion_type,
148
151
check_completion_type,
149
152
fix_completion_type);
150
153
static sys_var_collation_sv
151
sys_collation_server("collation_server", &system_variables::collation_server, &default_charset_info);
154
sys_collation_server("collation_server", &drizzle_system_variables::collation_server, &default_charset_info);
152
155
static sys_var_fs_path sys_datadir("datadir", getDataHome());
154
157
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size",
155
&system_variables::join_buff_size);
158
&drizzle_system_variables::join_buff_size);
156
159
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet",
157
&system_variables::max_allowed_packet);
158
static sys_var_uint64_t_ptr sys_max_connect_errors("max_connect_errors",
159
&max_connect_errors);
160
&drizzle_system_variables::max_allowed_packet);
160
161
static sys_var_session_uint64_t sys_max_error_count("max_error_count",
161
&system_variables::max_error_count);
162
&drizzle_system_variables::max_error_count);
162
163
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size",
163
&system_variables::max_heap_table_size);
164
&drizzle_system_variables::max_heap_table_size);
164
165
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id",
165
&system_variables::pseudo_thread_id,
166
&drizzle_system_variables::pseudo_thread_id,
166
167
0, check_pseudo_thread_id);
167
168
static sys_var_session_ha_rows sys_max_join_size("max_join_size",
168
&system_variables::max_join_size,
169
&drizzle_system_variables::max_join_size,
169
170
fix_max_join_size);
170
171
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key",
171
&system_variables::max_seeks_for_key);
172
&drizzle_system_variables::max_seeks_for_key);
172
173
static sys_var_session_uint64_t sys_max_length_for_sort_data("max_length_for_sort_data",
173
&system_variables::max_length_for_sort_data);
174
&drizzle_system_variables::max_length_for_sort_data);
174
175
static sys_var_session_size_t sys_max_sort_length("max_sort_length",
175
&system_variables::max_sort_length);
176
&drizzle_system_variables::max_sort_length);
176
177
static sys_var_uint64_t_ptr sys_max_write_lock_count("max_write_lock_count",
177
178
&max_write_lock_count);
178
179
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit",
179
&system_variables::min_examined_row_limit);
180
&drizzle_system_variables::min_examined_row_limit);
181
182
/* these two cannot be static */
182
183
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level",
183
&system_variables::optimizer_prune_level);
184
&drizzle_system_variables::optimizer_prune_level);
184
185
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth",
185
&system_variables::optimizer_search_depth);
186
&drizzle_system_variables::optimizer_search_depth);
187
188
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size",
188
&system_variables::preload_buff_size);
189
&drizzle_system_variables::preload_buff_size);
189
190
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size",
190
&system_variables::read_buff_size);
191
&drizzle_system_variables::read_buff_size);
191
192
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size",
192
&system_variables::read_rnd_buff_size);
193
&drizzle_system_variables::read_rnd_buff_size);
193
194
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment",
194
&system_variables::div_precincrement);
195
&drizzle_system_variables::div_precincrement);
196
197
static sys_var_session_size_t sys_range_alloc_block_size("range_alloc_block_size",
197
&system_variables::range_alloc_block_size);
198
&drizzle_system_variables::range_alloc_block_size);
200
static sys_var_session_bool sys_replicate_query("replicate_query",
201
&drizzle_system_variables::replicate_query);
198
203
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size",
199
&system_variables::query_alloc_block_size,
204
&drizzle_system_variables::query_alloc_block_size,
200
205
NULL, fix_session_mem_root);
201
206
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size",
202
&system_variables::query_prealloc_size,
207
&drizzle_system_variables::query_prealloc_size,
203
208
NULL, fix_session_mem_root);
204
209
static sys_var_readonly sys_tmpdir("tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
308
311
get_warning_count);
310
313
sys_var_session_uint64_t sys_group_concat_max_len("group_concat_max_len",
311
&system_variables::group_concat_max_len);
313
sys_var_session_time_zone sys_time_zone("time_zone");
314
&drizzle_system_variables::group_concat_max_len);
315
316
/* Global read-only variable containing hostname */
316
static sys_var_const_str sys_hostname("hostname", glob_hostname);
318
bool sys_var::check(Session *, set_var *var)
317
static sys_var_const_string sys_hostname("hostname", getServerHostname());
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);
324
bool sys_var::check(Session *session, set_var *var)
320
var->save_result.uint64_t_value= var->value->val_int();
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());
324
337
bool sys_var_str::check(Session *session, set_var *var)
330
343
if ((res=(*check_func)(session, var)) < 0)
331
344
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
348
bool sys_var_std_string::check(Session *session, set_var *var)
350
if (check_func == NULL)
355
int res= (*check_func)(session, var);
358
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
336
365
Functions to check and update variables
449
static bool get_unsigned32(Session *session, set_var *var)
451
if (var->value->unsigned_flag)
452
var->save_result.uint32_t_value=
453
static_cast<uint32_t>(var->value->val_int());
456
int64_t v= var->value->val_int();
458
throw_bounds_warning(session, true, true,var->var->getName().c_str(), v);
460
var->save_result.uint32_t_value=
461
static_cast<uint32_t>((v > UINT32_MAX) ? UINT32_MAX : (v < 0) ? 0 : v);
466
static bool get_unsigned64(Session *, set_var *var)
468
if (var->value->unsigned_flag)
469
var->save_result.uint64_t_value=(uint64_t) var->value->val_int();
472
int64_t v= var->value->val_int();
473
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
478
static bool get_size_t(Session *, set_var *var)
480
if (var->value->unsigned_flag)
481
var->save_result.size_t_value= (size_t) var->value->val_int();
484
ssize_t v= (ssize_t)var->value->val_int();
485
var->save_result.size_t_value= (size_t) ((v < 0) ? 0 : v);
490
478
bool sys_var_uint32_t_ptr::check(Session *, set_var *var)
492
var->save_result.uint32_t_value= (uint32_t)var->value->val_int();
496
484
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
498
uint32_t tmp= var->save_result.uint32_t_value;
499
LOCK_global_system_variables.lock();
486
uint64_t tmp= var->getInteger();
487
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
500
489
if (option_limits)
502
491
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
492
if(static_cast<uint64_t>(newvalue) == tmp)
504
493
*value= newvalue;
507
*value= (uint32_t) tmp;
508
LOCK_global_system_variables.unlock();
497
*value= static_cast<uint32_t>(tmp);
513
void sys_var_uint32_t_ptr::set_default(Session *, sql_var_t)
504
void sys_var_uint32_t_ptr::set_default(Session *session, sql_var_t)
516
LOCK_global_system_variables.lock();
507
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
517
508
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
518
509
option_limits, ¬_used);
519
LOCK_global_system_variables.unlock();
523
513
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
525
uint64_t tmp= var->save_result.uint64_t_value;
526
LOCK_global_system_variables.lock();
515
uint64_t tmp= var->getInteger();
516
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
527
518
if (option_limits)
529
uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits);
520
uint64_t newvalue= fix_unsigned(session, tmp, option_limits);
530
521
if(newvalue==tmp)
531
522
*value= newvalue;
534
*value= (uint64_t) tmp;
535
LOCK_global_system_variables.unlock();
540
void sys_var_uint64_t_ptr::set_default(Session *, sql_var_t)
533
void sys_var_uint64_t_ptr::set_default(Session *session, sql_var_t)
543
LOCK_global_system_variables.lock();
544
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
545
option_limits, ¬_used);
546
LOCK_global_system_variables.unlock();
535
if (have_default_value)
537
*value= default_value;
542
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
543
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
544
option_limits, ¬_used);
550
549
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
552
size_t tmp= var->save_result.size_t_value;
553
LOCK_global_system_variables.lock();
551
size_t tmp= size_t(var->getInteger());
553
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
554
555
if (option_limits)
555
556
*value= fix_size_t(session, tmp, option_limits);
558
LOCK_global_system_variables.unlock();
563
void sys_var_size_t_ptr::set_default(Session *, sql_var_t)
564
void sys_var_size_t_ptr::set_default(Session *session, sql_var_t)
566
LOCK_global_system_variables.lock();
567
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
567
568
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
568
569
option_limits, ¬_used);
569
LOCK_global_system_variables.unlock();
572
bool sys_var_bool_ptr::check(Session *session, set_var *var)
574
return check_enum(session, var, &bool_typelib);
572
577
bool sys_var_bool_ptr::update(Session *, set_var *var)
574
*value= (bool) var->save_result.uint32_t_value;
579
*value= bool(var->getInteger());
579
584
void sys_var_bool_ptr::set_default(Session *, sql_var_t)
581
*value= (bool) option_limits->def_value;
586
*value= default_value;
899
LOCK_global_system_variables.lock();
923
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
900
924
value= *(uint*) value_ptr(session, var_type, base);
901
LOCK_global_system_variables.unlock();
902
926
return new Item_uint((uint64_t) value);
904
928
case SHOW_LONGLONG:
907
LOCK_global_system_variables.lock();
931
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
908
932
value= *(int64_t*) value_ptr(session, var_type, base);
909
LOCK_global_system_variables.unlock();
910
934
return new Item_int(value);
912
936
case SHOW_DOUBLE:
915
LOCK_global_system_variables.lock();
916
value= *(double*) value_ptr(session, var_type, base);
917
LOCK_global_system_variables.unlock();
940
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
941
value= *(double*) value_ptr(session, var_type, base);
918
944
/* 6, as this is for now only used with microseconds */
919
945
return new Item_float(value, 6);
921
947
case SHOW_HA_ROWS:
924
LOCK_global_system_variables.lock();
950
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
925
951
value= *(ha_rows*) value_ptr(session, var_type, base);
926
LOCK_global_system_variables.unlock();
927
953
return new Item_int((uint64_t) value);
932
LOCK_global_system_variables.lock();
958
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
933
959
value= *(size_t*) value_ptr(session, var_type, base);
934
LOCK_global_system_variables.unlock();
935
961
return new Item_int((uint64_t) value);
937
963
case SHOW_MY_BOOL:
940
LOCK_global_system_variables.lock();
966
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
941
967
value= *(bool*) value_ptr(session, var_type, base);
942
LOCK_global_system_variables.unlock();
943
968
return new Item_int(value,1);
945
970
case SHOW_CHAR_PTR:
948
LOCK_global_system_variables.lock();
973
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
949
974
char *str= *(char**) value_ptr(session, var_type, base);
1156
1169
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1160
bool sys_var_session_time_zone::check(Session *session, set_var *var)
1162
char buff[MAX_TIME_ZONE_NAME_LENGTH];
1163
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
1164
String *res= var->value->val_str(&str);
1166
if (!(var->save_result.time_zone= my_tz_find(session, res)))
1168
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
1175
bool sys_var_session_time_zone::update(Session *session, set_var *var)
1177
/* We are using Time_zone object found during check() phase. */
1178
if (var->type == OPT_GLOBAL)
1180
LOCK_global_system_variables.lock();
1181
global_system_variables.time_zone= var->save_result.time_zone;
1182
LOCK_global_system_variables.unlock();
1185
session->variables.time_zone= var->save_result.time_zone;
1190
unsigned char *sys_var_session_time_zone::value_ptr(Session *session,
1195
We can use ptr() instead of c_ptr() here because String contaning
1196
time zone name is guaranteed to be zero ended.
1198
if (type == OPT_GLOBAL)
1199
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
1203
This is an ugly fix for replication: we don't replicate properly queries
1204
invoking system variables' values to update tables; but
1205
CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
1206
replicable (i.e. we tell the binlog code to store the session
1207
timezone). If it's the global value which was used we can't replicate
1208
(binlog code stores session value only).
1210
return (unsigned char *)(session->variables.time_zone->get_name()->ptr());
1215
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
1217
LOCK_global_system_variables.lock();
1218
if (type == OPT_GLOBAL)
1220
if (default_tz_name)
1222
String str(default_tz_name, &my_charset_utf8_general_ci);
1224
We are guaranteed to find this time zone since its existence
1225
is checked during start-up.
1227
global_system_variables.time_zone= my_tz_find(session, &str);
1230
global_system_variables.time_zone= my_tz_SYSTEM;
1233
session->variables.time_zone= global_system_variables.time_zone;
1234
LOCK_global_system_variables.unlock();
1238
bool sys_var_session_lc_time_names::check(Session *, set_var *var)
1172
bool sys_var_session_lc_time_names::update(Session *session, set_var *var)
1240
1174
MY_LOCALE *locale_match;
1361
1286
static bool set_option_autocommit(Session *session, set_var *var)
1363
1289
/* The test is negative as the flag we use is NOT autocommit */
1365
1291
uint64_t org_options= session->options;
1292
uint64_t new_options= session->options;
1367
if (var->save_result.uint32_t_value != 0)
1368
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1294
if (var->getInteger() != 0)
1295
new_options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1370
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
1297
new_options|= ((sys_var_session_bit*) var->var)->bit_flag;
1372
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
1299
if ((org_options ^ new_options) & OPTION_NOT_AUTOCOMMIT)
1374
1301
if ((org_options & OPTION_NOT_AUTOCOMMIT))
1303
success= session->endActiveTransaction();
1376
1304
/* We changed to auto_commit mode */
1377
1305
session->options&= ~(uint64_t) (OPTION_BEGIN);
1378
1306
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1379
TransactionServices &transaction_services= TransactionServices::singleton();
1380
if (transaction_services.commitTransaction(session, true))
1385
1310
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1314
if (var->getInteger() != 0)
1315
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1317
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
1391
1325
static int check_pseudo_thread_id(Session *, set_var *var)
1393
var->save_result.uint64_t_value= var->value->val_int();
1607
1545
add_sys_var_to_list(&sys_sql_notes, my_long_options);
1608
1546
add_sys_var_to_list(&sys_sql_warnings, my_long_options);
1609
1547
add_sys_var_to_list(&sys_storage_engine, my_long_options);
1610
add_sys_var_to_list(&sys_system_time_zone, my_long_options);
1611
1548
add_sys_var_to_list(&sys_table_cache_size, my_long_options);
1612
1549
add_sys_var_to_list(&sys_table_def_size, my_long_options);
1613
1550
add_sys_var_to_list(&sys_table_lock_wait_timeout, my_long_options);
1614
1551
add_sys_var_to_list(&sys_thread_stack_size, my_long_options);
1615
add_sys_var_to_list(&sys_time_zone, my_long_options);
1616
1552
add_sys_var_to_list(&sys_timed_mutexes, my_long_options);
1617
1553
add_sys_var_to_list(&sys_timestamp, my_long_options);
1618
1554
add_sys_var_to_list(&sys_tmp_table_size, my_long_options);
1664
1597
result= (*iter).second;
1668
This function is only called from the sql_plugin.cc.
1669
A lock on LOCK_system_variable_hash should be held
1671
1600
if (result == NULL)
1679
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
1602
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), name.c_str());
1689
Execute update of all variables.
1691
First run a check of all variables that all updates will go ok.
1692
If yes, then execute all updates, returning an error if any one failed.
1694
This should ensure that in all normal cases none all or variables are
1697
@param Session Thread id
1698
@param var_list List of variables to update
1703
1 ERROR, message sent (normally no variables was updated)
1705
-1 ERROR, message not sent
1708
int sql_set_variables(Session *session, List<set_var_base> *var_list)
1711
List_iterator_fast<set_var_base> it(*var_list);
1716
if ((error= var->check(session)))
1719
if (!(error= test(session->is_error())))
1723
error|= var->update(session); // Returns 0, -1 or 1
1727
free_underlaid_joins(session, &session->lex->select_lex);
1732
/*****************************************************************************
1733
Functions to handle SET mysql_internal_variable=const_expr
1734
*****************************************************************************/
1736
int set_var::check(Session *session)
1738
if (var->is_readonly())
1740
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->getName().c_str(), "read only");
1743
if (var->check_type(type))
1745
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
1746
my_error(err, MYF(0), var->getName().c_str());
1749
/* value is a NULL pointer if we are using SET ... = DEFAULT */
1752
if (var->check_default(type))
1754
my_error(ER_NO_DEFAULT, MYF(0), var->getName().c_str());
1760
if ((!value->fixed &&
1761
value->fix_fields(session, &value)) || value->check_cols(1))
1763
if (var->check_update_type(value->result_type()))
1765
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->getName().c_str());
1768
return var->check(session, this) ? -1 : 0;
1774
@param session thread handler
1775
@returns 0|1 ok or ERROR
1777
@note ERROR can be only due to abnormal operations involving
1778
the server's execution evironment such as
1779
out of memory, hard disk failure or the computer blows up.
1780
Consider set_var::check() method if there is a need to return
1781
an error due to logics.
1783
int set_var::update(Session *session)
1786
var->set_default(session, type);
1787
else if (var->update(session, this))
1788
return -1; // should never happen
1789
if (var->getAfterUpdateTrigger())
1790
(*var->getAfterUpdateTrigger())(session, type);
1794
/*****************************************************************************
1795
Functions to handle SET @user_variable=const_expr
1796
*****************************************************************************/
1798
int set_var_user::check(Session *session)
1801
Item_func_set_user_var can't substitute something else on its place =>
1802
0 can be passed as last argument (reference on item)
1804
return (user_var_item->fix_fields(session, (Item**) 0) ||
1805
user_var_item->check(0)) ? -1 : 0;
1809
int set_var_user::update(Session *)
1811
if (user_var_item->update())
1813
/* Give an error if it's not given already */
1814
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0));
1820
1610
/****************************************************************************
1821
1611
Functions to handle table_type
1822
1612
****************************************************************************/
1824
/* Based upon sys_var::check_enum() */
1826
bool sys_var_session_storage_engine::check(Session *session, set_var *var)
1828
char buff[STRING_BUFFER_USUAL_SIZE];
1830
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
1832
var->save_result.storage_engine= NULL;
1833
if (var->value->result_type() == STRING_RESULT)
1835
res= var->value->val_str(&str);
1836
if (res == NULL || res->ptr() == NULL)
1843
const std::string engine_name(res->ptr());
1844
plugin::StorageEngine *engine;
1845
var->save_result.storage_engine= plugin::StorageEngine::findByName(*session, engine_name);
1846
if (var->save_result.storage_engine == NULL)
1848
value= res->c_ptr();
1851
engine= var->save_result.storage_engine;
1858
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value);
1863
1614
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session,
1864
1615
sql_var_t type,
1865
1616
const LEX_STRING *)
1898
1649
bool sys_var_session_storage_engine::update(Session *session, set_var *var)
1900
plugin::StorageEngine **value= &(global_system_variables.*offset), *old_value;
1651
char buff[STRING_BUFFER_USUAL_SIZE];
1652
const char *name_value;
1653
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
1655
plugin::StorageEngine *tmp= NULL;
1656
plugin::StorageEngine **value= NULL;
1658
if (var->value->result_type() == STRING_RESULT)
1660
res= var->value->val_str(&str);
1661
if (res == NULL || res->ptr() == NULL)
1668
const std::string engine_name(res->ptr());
1669
tmp= plugin::StorageEngine::findByName(*session, engine_name);
1672
name_value= res->c_ptr();
1679
name_value= "unknown";
1682
value= &(global_system_variables.*offset);
1901
1683
if (var->type != OPT_GLOBAL)
1902
1684
value= &(session->variables.*offset);
1904
if (old_value != var->save_result.storage_engine)
1906
*value= var->save_result.storage_engine;
1691
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name_value);
1911
1695
} /* namespace drizzled */