2013-05-07 13:05:09 +02:00
|
|
|
/* Copyright (c) 2002, 2013, Oracle and/or its affiliates.
|
2014-02-17 11:00:51 +01:00
|
|
|
Copyright (c) 2008, 2014, SkySQL Ab.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-30 17:46:53 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/* variable declarations are in sys_vars.cc now !!! */
|
2005-11-07 16:25:06 +01:00
|
|
|
|
2014-09-30 19:31:14 +02:00
|
|
|
#include "sql_plugin.h" // Includes my_global.h
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_class.h" // set_var.h: session_var_ptr
|
|
|
|
#include "set_var.h"
|
|
|
|
#include "sql_priv.h"
|
|
|
|
#include "unireg.h"
|
|
|
|
#include "mysqld.h" // lc_messages_dir
|
2009-12-22 10:35:56 +01:00
|
|
|
#include "sys_vars_shared.h"
|
2009-12-03 19:37:38 +01:00
|
|
|
#include "transaction.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_locale.h" // my_locale_by_number,
|
|
|
|
// my_locale_by_name
|
|
|
|
#include "strfunc.h" // find_set_from_flags, find_set
|
|
|
|
#include "sql_parse.h" // check_global_access
|
|
|
|
#include "sql_table.h" // reassign_keycache_tables
|
|
|
|
#include "sql_time.h" // date_time_format_copy,
|
|
|
|
// date_time_format_make
|
|
|
|
#include "derror.h"
|
|
|
|
#include "tztime.h" // my_tz_find, my_tz_SYSTEM, struct Time_zone
|
|
|
|
#include "sql_acl.h" // SUPER_ACL
|
|
|
|
#include "sql_select.h" // free_underlaid_joins
|
2014-09-03 20:16:51 +02:00
|
|
|
#include "sql_show.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_view.h" // updatable_views_with_limit_typelib
|
|
|
|
#include "lock.h" // lock_global_read_lock,
|
|
|
|
// make_global_read_lock_block_commit,
|
|
|
|
// unlock_global_read_lock
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
static HASH system_variable_hash;
|
2009-12-22 10:35:56 +01:00
|
|
|
static PolyLock_mutex PLock_global_system_variables(&LOCK_global_system_variables);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-10-29 12:19:36 +01:00
|
|
|
/**
|
2009-12-22 10:35:56 +01:00
|
|
|
Return variable name and length for hashing of variables.
|
2009-10-29 12:19:36 +01:00
|
|
|
*/
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
|
|
|
|
my_bool first)
|
2002-08-13 01:18:39 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
*length= var->name.length;
|
|
|
|
return (uchar*) var->name.str;
|
2002-08-13 01:18:39 +02:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
sys_var_chain all_sys_vars = { NULL, NULL };
|
2007-12-12 11:14:59 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
int sys_var_init()
|
2007-12-12 11:14:59 +01:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_ENTER("sys_var_init");
|
2007-12-12 11:14:59 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
/* Must be already initialized. */
|
|
|
|
DBUG_ASSERT(system_charset_info != NULL);
|
2007-12-12 11:14:59 +01:00
|
|
|
|
2016-04-28 10:28:02 +02:00
|
|
|
if (my_hash_init(&system_variable_hash, system_charset_info, 700, 0,
|
2009-12-22 10:35:56 +01:00
|
|
|
0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
|
|
|
|
goto error;
|
2009-10-15 14:23:43 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
if (mysql_add_sys_var_chain(all_sys_vars.first))
|
|
|
|
goto error;
|
2009-10-15 14:23:43 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_RETURN(0);
|
2009-10-15 14:23:43 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
error:
|
|
|
|
fprintf(stderr, "failed to initialize System variables");
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
|
2016-04-28 10:28:02 +02:00
|
|
|
uint sys_var_elements()
|
|
|
|
{
|
|
|
|
return system_variable_hash.records;
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags)
|
|
|
|
{
|
|
|
|
uint saved_elements= long_options->elements;
|
|
|
|
|
|
|
|
DBUG_ENTER("sys_var_add_options");
|
|
|
|
|
|
|
|
for (sys_var *var=all_sys_vars.first; var; var= var->next)
|
|
|
|
{
|
|
|
|
if (var->register_option(long_options, parse_flags))
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
error:
|
|
|
|
fprintf(stderr, "failed to initialize System variables");
|
|
|
|
long_options->elements= saved_elements;
|
|
|
|
DBUG_RETURN(1);
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
void sys_var_end()
|
2006-07-04 14:40:40 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_ENTER("sys_var_end");
|
2006-07-04 14:40:40 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
my_hash_free(&system_variable_hash);
|
2006-07-04 14:40:40 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
for (sys_var *var=all_sys_vars.first; var; var= var->next)
|
2010-09-02 20:37:04 +02:00
|
|
|
var->cleanup();
|
2006-07-04 14:40:40 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_VOID_RETURN;
|
2006-07-04 14:40:40 +02:00
|
|
|
}
|
2004-12-29 18:30:37 +01:00
|
|
|
|
2016-04-15 20:47:45 +02:00
|
|
|
|
|
|
|
static bool static_test_load= TRUE;
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
sys_var constructor
|
|
|
|
|
|
|
|
@param chain variables are linked into chain for mysql_add_sys_var_chain()
|
2011-05-21 10:21:08 +02:00
|
|
|
@param name_arg the name of the variable. Must be 0-terminated and exist
|
|
|
|
for the liftime of the sys_var object. @sa my_option::name
|
2009-12-22 10:35:56 +01:00
|
|
|
@param comment shown in mysqld --help, @sa my_option::comment
|
|
|
|
@param flags_arg or'ed flag_enum values
|
|
|
|
@param off offset of the global variable value from the
|
|
|
|
&global_system_variables.
|
|
|
|
@param getopt_id -1 for no command-line option, otherwise @sa my_option::id
|
|
|
|
@param getopt_arg_type @sa my_option::arg_type
|
|
|
|
@param show_val_type_arg what value_ptr() returns for sql_show.cc
|
|
|
|
@param def_val default value, @sa my_option::def_value
|
|
|
|
@param lock mutex or rw_lock that protects the global variable
|
|
|
|
*in addition* to LOCK_global_system_variables.
|
|
|
|
@param binlog_status_enum @sa binlog_status_enum
|
|
|
|
@param on_check_func a function to be called at the end of sys_var::check,
|
|
|
|
put your additional checks here
|
|
|
|
@param on_update_func a function to be called at the end of sys_var::update,
|
|
|
|
any post-update activity should happen here
|
2012-08-24 10:17:08 +02:00
|
|
|
@param substitute If non-NULL, this variable is deprecated and the
|
|
|
|
string describes what one should use instead. If an empty string,
|
|
|
|
the variable is deprecated but no replacement is offered.
|
2009-12-22 10:35:56 +01:00
|
|
|
*/
|
|
|
|
sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
|
|
|
|
const char *comment, int flags_arg, ptrdiff_t off,
|
|
|
|
int getopt_id, enum get_opt_arg_type getopt_arg_type,
|
|
|
|
SHOW_TYPE show_val_type_arg, longlong def_val,
|
|
|
|
PolyLock *lock, enum binlog_status_enum binlog_status_arg,
|
|
|
|
on_check_function on_check_func,
|
|
|
|
on_update_function on_update_func,
|
2012-10-16 13:04:42 +02:00
|
|
|
const char *substitute) :
|
2014-09-01 20:29:58 +02:00
|
|
|
next(0), binlog_status(binlog_status_arg), value_origin(COMPILE_TIME),
|
2011-07-11 20:33:39 +02:00
|
|
|
flags(flags_arg), show_val_type(show_val_type_arg),
|
2009-12-22 10:35:56 +01:00
|
|
|
guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func),
|
2012-08-24 10:17:08 +02:00
|
|
|
deprecation_substitute(substitute),
|
2015-04-09 11:14:57 +02:00
|
|
|
is_os_charset(FALSE)
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
2010-08-26 02:59:28 +02:00
|
|
|
/*
|
|
|
|
There is a limitation in handle_options() related to short options:
|
|
|
|
- either all short options should be declared when parsing in multiple stages,
|
|
|
|
- or none should be declared.
|
|
|
|
Because a lot of short options are used in the normal parsing phase
|
|
|
|
for mysqld, we enforce here that no short option is present
|
|
|
|
in the first (PARSE_EARLY) stage.
|
|
|
|
See handle_options() for details.
|
|
|
|
*/
|
2011-07-11 20:33:39 +02:00
|
|
|
DBUG_ASSERT(!(flags & PARSE_EARLY) || getopt_id <= 0 || getopt_id >= 255);
|
2010-08-26 02:59:28 +02:00
|
|
|
|
2011-05-21 10:21:08 +02:00
|
|
|
name.str= name_arg; // ER_NO_DEFAULT relies on 0-termination of name_arg
|
|
|
|
name.length= strlen(name_arg); // and so does this.
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_ASSERT(name.length <= NAME_CHAR_LEN);
|
|
|
|
|
|
|
|
bzero(&option, sizeof(option));
|
|
|
|
option.name= name_arg;
|
|
|
|
option.id= getopt_id;
|
|
|
|
option.comment= comment;
|
|
|
|
option.arg_type= getopt_arg_type;
|
|
|
|
option.value= (uchar **)global_var_ptr();
|
|
|
|
option.def_value= def_val;
|
2014-09-01 20:29:58 +02:00
|
|
|
option.app_type= this;
|
2015-09-03 18:06:55 +02:00
|
|
|
option.var_type= flags & AUTO_SET ? GET_AUTO : 0;
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
if (chain->last)
|
|
|
|
chain->last->next= this;
|
|
|
|
else
|
|
|
|
chain->first= this;
|
|
|
|
chain->last= this;
|
2016-04-15 20:47:45 +02:00
|
|
|
|
|
|
|
test_load= &static_test_load;
|
2009-12-22 10:35:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool sys_var::update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
enum_var_type type= var->type;
|
|
|
|
if (type == OPT_GLOBAL || scope() == GLOBAL)
|
2009-10-15 14:23:43 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
/*
|
|
|
|
Yes, both locks need to be taken before an update, just as
|
|
|
|
both are taken to get a value. If we'll take only 'guard' here,
|
|
|
|
then value_ptr() for strings won't be safe in SHOW VARIABLES anymore,
|
|
|
|
to make it safe we'll need value_ptr_unlock().
|
|
|
|
*/
|
|
|
|
AutoWLock lock1(&PLock_global_system_variables);
|
|
|
|
AutoWLock lock2(guard);
|
2014-09-01 20:29:58 +02:00
|
|
|
value_origin= SQL;
|
2009-12-22 10:35:56 +01:00
|
|
|
return global_update(thd, var) ||
|
|
|
|
(on_update && on_update(this, thd, OPT_GLOBAL));
|
2009-10-15 14:23:43 +02:00
|
|
|
}
|
|
|
|
else
|
2016-04-15 20:40:25 +02:00
|
|
|
{
|
|
|
|
bool ret= session_update(thd, var) ||
|
2009-12-22 10:35:56 +01:00
|
|
|
(on_update && on_update(this, thd, OPT_SESSION));
|
2016-04-15 20:40:25 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Make sure we don't session-track variables that are not actually
|
|
|
|
part of the session. tx_isolation and and tx_read_only for example
|
|
|
|
exist as GLOBAL, SESSION, and one-shot ("for next transaction only").
|
|
|
|
*/
|
|
|
|
if ((var->type == OPT_SESSION) && (!ret))
|
|
|
|
{
|
2016-05-30 21:22:50 +02:00
|
|
|
SESSION_TRACKER_CHANGED(thd, SESSION_SYSVARS_TRACKER,
|
|
|
|
(LEX_CSTRING*)var->var);
|
2016-04-15 20:40:25 +02:00
|
|
|
/*
|
|
|
|
Here MySQL sends variable name to avoid reporting change of
|
|
|
|
the tracker itself, but we decided that it is not needed
|
|
|
|
*/
|
2016-05-30 21:22:50 +02:00
|
|
|
SESSION_TRACKER_CHANGED(thd, SESSION_STATE_CHANGE_TRACKER, NULL);
|
2016-04-15 20:40:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2009-10-15 14:23:43 +02:00
|
|
|
}
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
uchar *sys_var::session_value_ptr(THD *thd, const LEX_CSTRING *base)
|
2009-10-15 14:23:43 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
return session_var_ptr(thd);
|
2009-10-15 14:23:43 +02:00
|
|
|
}
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base)
|
2009-10-15 14:23:43 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
return global_var_ptr();
|
2009-10-15 14:23:43 +02:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
bool sys_var::check(THD *thd, set_var *var)
|
2007-07-30 10:33:50 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
if ((var->value && do_check(thd, var))
|
|
|
|
|| (on_check && on_check(this, thd, var)))
|
2007-07-30 10:33:50 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
if (!thd->is_error())
|
|
|
|
{
|
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
|
|
|
String str(buff, sizeof(buff), system_charset_info), *res;
|
|
|
|
|
|
|
|
if (!var->value)
|
|
|
|
{
|
|
|
|
str.set(STRING_WITH_LEN("DEFAULT"), &my_charset_latin1);
|
|
|
|
res= &str;
|
|
|
|
}
|
|
|
|
else if (!(res=var->value->val_str(&str)))
|
|
|
|
{
|
|
|
|
str.set(STRING_WITH_LEN("NULL"), &my_charset_latin1);
|
|
|
|
res= &str;
|
|
|
|
}
|
|
|
|
ErrConvString err(res);
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.str, err.ptr());
|
|
|
|
}
|
|
|
|
return true;
|
2007-07-30 10:33:50 +02:00
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
return false;
|
2007-07-30 10:33:50 +02:00
|
|
|
}
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
uchar *sys_var::value_ptr(THD *thd, enum_var_type type,
|
|
|
|
const LEX_CSTRING *base)
|
2007-07-30 10:33:50 +02:00
|
|
|
{
|
2014-09-03 20:16:51 +02:00
|
|
|
DBUG_ASSERT(base);
|
2009-12-22 10:35:56 +01:00
|
|
|
if (type == OPT_GLOBAL || scope() == GLOBAL)
|
2007-07-30 10:33:50 +02:00
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_global_system_variables);
|
2009-12-22 10:35:56 +01:00
|
|
|
AutoRLock lock(guard);
|
|
|
|
return global_value_ptr(thd, base);
|
2007-07-30 10:33:50 +02:00
|
|
|
}
|
|
|
|
else
|
2009-12-22 10:35:56 +01:00
|
|
|
return session_value_ptr(thd, base);
|
2007-07-30 10:33:50 +02:00
|
|
|
}
|
|
|
|
|
2013-02-25 05:58:25 +01:00
|
|
|
bool sys_var::set_default(THD *thd, set_var* var)
|
2007-07-30 10:33:50 +02:00
|
|
|
{
|
2013-02-25 05:58:25 +01:00
|
|
|
if (var->type == OPT_GLOBAL || scope() == GLOBAL)
|
|
|
|
global_save_default(thd, var);
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
2013-02-25 05:58:25 +01:00
|
|
|
session_save_default(thd, var);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2013-02-25 05:58:25 +01:00
|
|
|
return check(thd, var) || update(thd, var);
|
2009-03-05 19:39:02 +01:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2013-04-09 23:27:19 +02:00
|
|
|
|
2014-08-31 13:39:05 +02:00
|
|
|
#define do_num_val(T,CMD) \
|
|
|
|
do { \
|
|
|
|
T val= *(T*) value; \
|
|
|
|
CMD; \
|
2013-04-09 23:27:19 +02:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define case_for_integers(CMD) \
|
|
|
|
case SHOW_SINT: do_num_val (int,CMD); \
|
|
|
|
case SHOW_SLONG: do_num_val (long,CMD); \
|
|
|
|
case SHOW_SLONGLONG:do_num_val (longlong,CMD); \
|
|
|
|
case SHOW_UINT: do_num_val (uint,CMD); \
|
|
|
|
case SHOW_ULONG: do_num_val (ulong,CMD); \
|
|
|
|
case SHOW_ULONGLONG:do_num_val (ulonglong,CMD); \
|
2014-09-03 20:05:51 +02:00
|
|
|
case SHOW_HA_ROWS: do_num_val (ha_rows,CMD);
|
2013-04-09 23:27:19 +02:00
|
|
|
|
2014-08-31 13:39:05 +02:00
|
|
|
#define case_for_double(CMD) \
|
2013-04-09 23:27:19 +02:00
|
|
|
case SHOW_DOUBLE: do_num_val (double,CMD)
|
|
|
|
|
2014-08-31 13:39:05 +02:00
|
|
|
#define case_get_string_as_lex_string \
|
|
|
|
case SHOW_CHAR: \
|
|
|
|
sval.str= (char*) value; \
|
|
|
|
sval.length= sval.str ? strlen(sval.str) : 0; \
|
|
|
|
break; \
|
|
|
|
case SHOW_CHAR_PTR: \
|
|
|
|
sval.str= *(char**) value; \
|
|
|
|
sval.length= sval.str ? strlen(sval.str) : 0; \
|
|
|
|
break; \
|
|
|
|
case SHOW_LEX_STRING: \
|
|
|
|
sval= *(LEX_STRING *) value; \
|
2013-04-09 23:27:19 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
longlong sys_var::val_int(bool *is_null,
|
2017-04-23 18:39:57 +02:00
|
|
|
THD *thd, enum_var_type type,
|
|
|
|
const LEX_CSTRING *base)
|
2013-04-09 23:27:19 +02:00
|
|
|
{
|
|
|
|
LEX_STRING sval;
|
2014-08-31 13:39:05 +02:00
|
|
|
AutoWLock lock(&PLock_global_system_variables);
|
|
|
|
const uchar *value= value_ptr(thd, type, base);
|
2013-04-09 23:27:19 +02:00
|
|
|
*is_null= false;
|
2014-08-31 13:39:05 +02:00
|
|
|
|
2013-04-09 23:27:19 +02:00
|
|
|
switch (show_type())
|
|
|
|
{
|
|
|
|
case_get_string_as_lex_string;
|
|
|
|
case_for_integers(return val);
|
2013-05-05 20:39:31 +02:00
|
|
|
case_for_double(return (longlong) val);
|
2014-09-03 20:05:51 +02:00
|
|
|
case SHOW_MY_BOOL: return *(my_bool*)value;
|
2013-04-09 23:27:19 +02:00
|
|
|
default:
|
|
|
|
my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
longlong ret= 0;
|
|
|
|
if (!(*is_null= !sval.str))
|
2014-09-03 20:05:51 +02:00
|
|
|
ret= longlong_from_string_with_check(charset(thd),
|
2013-04-09 23:27:19 +02:00
|
|
|
sval.str, sval.str + sval.length);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-31 13:39:05 +02:00
|
|
|
String *sys_var::val_str_nolock(String *str, THD *thd, const uchar *value)
|
2013-04-09 23:27:19 +02:00
|
|
|
{
|
2014-09-03 20:05:51 +02:00
|
|
|
static LEX_STRING bools[]=
|
|
|
|
{
|
|
|
|
{ C_STRING_WITH_LEN("OFF") },
|
|
|
|
{ C_STRING_WITH_LEN("ON") }
|
|
|
|
};
|
|
|
|
|
2013-04-09 23:27:19 +02:00
|
|
|
LEX_STRING sval;
|
|
|
|
switch (show_type())
|
|
|
|
{
|
|
|
|
case_get_string_as_lex_string;
|
2014-09-03 20:05:51 +02:00
|
|
|
case_for_integers(return str->set(val, system_charset_info) ? 0 : str);
|
2013-04-09 23:27:19 +02:00
|
|
|
case_for_double(return str->set_real(val, 6, system_charset_info) ? 0 : str);
|
2014-09-03 20:05:51 +02:00
|
|
|
case SHOW_MY_BOOL:
|
|
|
|
sval= bools[(int)*(my_bool*)value];
|
|
|
|
break;
|
2013-04-09 23:27:19 +02:00
|
|
|
default:
|
|
|
|
my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-03 20:05:51 +02:00
|
|
|
if (!sval.str || str->copy(sval.str, sval.length, charset(thd)))
|
2013-04-09 23:27:19 +02:00
|
|
|
str= NULL;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-31 13:39:05 +02:00
|
|
|
String *sys_var::val_str(String *str,
|
2017-04-23 18:39:57 +02:00
|
|
|
THD *thd, enum_var_type type, const LEX_CSTRING *base)
|
2014-08-31 13:39:05 +02:00
|
|
|
{
|
|
|
|
AutoWLock lock(&PLock_global_system_variables);
|
|
|
|
const uchar *value= value_ptr(thd, type, base);
|
|
|
|
return val_str_nolock(str, thd, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-09 23:27:19 +02:00
|
|
|
double sys_var::val_real(bool *is_null,
|
2017-04-23 18:39:57 +02:00
|
|
|
THD *thd, enum_var_type type, const LEX_CSTRING *base)
|
2013-04-09 23:27:19 +02:00
|
|
|
{
|
|
|
|
LEX_STRING sval;
|
2014-08-31 13:39:05 +02:00
|
|
|
AutoWLock lock(&PLock_global_system_variables);
|
|
|
|
const uchar *value= value_ptr(thd, type, base);
|
2013-04-09 23:27:19 +02:00
|
|
|
*is_null= false;
|
2014-08-31 13:39:05 +02:00
|
|
|
|
2013-04-09 23:27:19 +02:00
|
|
|
switch (show_type())
|
|
|
|
{
|
|
|
|
case_get_string_as_lex_string;
|
2017-03-10 20:06:33 +01:00
|
|
|
case_for_integers(return (double)val);
|
2013-04-09 23:27:19 +02:00
|
|
|
case_for_double(return val);
|
2014-09-03 20:05:51 +02:00
|
|
|
case SHOW_MY_BOOL: return *(my_bool*)value;
|
2013-04-09 23:27:19 +02:00
|
|
|
default:
|
|
|
|
my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double ret= 0;
|
|
|
|
if (!(*is_null= !sval.str))
|
2014-09-03 20:05:51 +02:00
|
|
|
ret= double_from_string_with_check(charset(thd),
|
2013-04-09 23:27:19 +02:00
|
|
|
sval.str, sval.str + sval.length);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
void sys_var::do_deprecated_warning(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2012-08-24 10:17:08 +02:00
|
|
|
if (deprecation_substitute != NULL)
|
Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5,
2617.31.12, 2617.31.15, 2617.31.15, 2617.31.16, 2617.43.1
- initial changeset that introduced the fix for
Bug#989 and follow up fixes for all test suite failures
introduced in the initial changeset.
------------------------------------------------------------
revno: 2617.31.1
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: 4284-6.0
timestamp: Fri 2009-03-06 19:17:00 -0300
message:
Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order
WL#4284: Transactional DDL locking
Currently the MySQL server does not keep metadata locks on
schema objects for the duration of a transaction, thus failing
to guarantee the integrity of the schema objects being used
during the transaction and to protect then from concurrent
DDL operations. This also poses a problem for replication as
a DDL operation might be replicated even thought there are
active transactions using the object being modified.
The solution is to defer the release of metadata locks until
a active transaction is either committed or rolled back. This
prevents other statements from modifying the table for the
entire duration of the transaction. This provides commitment
ordering for guaranteeing serializability across multiple
transactions.
- Incompatible change:
If MySQL's metadata locking system encounters a lock conflict,
the usual schema is to use the try and back-off technique to
avoid deadlocks -- this schema consists in releasing all locks
and trying to acquire them all in one go.
But in a transactional context this algorithm can't be utilized
as its not possible to release locks acquired during the course
of the transaction without breaking the transaction commitments.
To avoid deadlocks in this case, the ER_LOCK_DEADLOCK will be
returned if a lock conflict is encountered during a transaction.
Let's consider an example:
A transaction has two statements that modify table t1, then table
t2, and then commits. The first statement of the transaction will
acquire a shared metadata lock on table t1, and it will be kept
utill COMMIT to ensure serializability.
At the moment when the second statement attempts to acquire a
shared metadata lock on t2, a concurrent ALTER or DROP statement
might have locked t2 exclusively. The prescription of the current
locking protocol is that the acquirer of the shared lock backs off
-- gives up all his current locks and retries. This implies that
the entire multi-statement transaction has to be rolled back.
- Incompatible change:
FLUSH commands such as FLUSH PRIVILEGES and FLUSH TABLES WITH READ
LOCK won't cause locked tables to be implicitly unlocked anymore.
mysql-test/extra/binlog_tests/drop_table.test:
Add test case for Bug#989.
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/include/mix1.inc:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/include/mix2.inc:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/r/flush_block_commit.result:
Update test case result (WL#4284).
mysql-test/r/flush_block_commit_notembedded.result:
Update test case result (WL#4284).
mysql-test/r/innodb.result:
Update test case result (WL#4284).
mysql-test/r/innodb_mysql.result:
Update test case result (WL#4284).
mysql-test/r/lock.result:
Add test case result for an effect of WL#4284/Bug#989
(all locks should be released when a connection terminates).
mysql-test/r/mix2_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/r/not_embedded_server.result:
Update test case result (effects of WL#4284/Bug#989).
Add a test case for interaction of WL#4284 and FLUSH PRIVILEGES.
mysql-test/r/partition_innodb_semi_consistent.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/r/partition_sync.result:
Temporarily disable the test case for Bug#43867,
which will be fixed by a subsequent backport.
mysql-test/r/ps.result:
Add a test case for effect of PREPARE on transactional
locks: we take a savepoint at beginning of PREAPRE
and release it at the end. Thus PREPARE does not
accumulate metadata locks (Bug#989/WL#4284).
mysql-test/r/read_only_innodb.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_row_drop_tbl.result:
Add a test case result (WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_stm_drop_tbl.result:
Add a test case result (WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_unsafe.result:
A side effect of Bug#989 -- slightly different table map ids.
mysql-test/suite/binlog/t/binlog_row_drop_tbl.test:
Add a test case for WL#4284/Bug#989.
mysql-test/suite/binlog/t/binlog_stm_drop_tbl.test:
Add a test case for WL#4284/Bug#989.
mysql-test/suite/binlog/t/binlog_stm_row.test:
Update to the new state name. This
is actually a follow up to another patch for WL#4284,
that changes Locked thread state to Table lock.
mysql-test/suite/ndb/r/ndb_index_ordered.result:
Remove result for disabled part of the test case.
mysql-test/suite/ndb/t/disabled.def:
Temporarily disable a test case (Bug#45621).
mysql-test/suite/ndb/t/ndb_index_ordered.test:
Disable a part of a test case (needs update to
reflect semantics of Bug#989).
mysql-test/suite/rpl/t/disabled.def:
Disable tests made meaningless by transactional metadata
locking.
mysql-test/suite/sys_vars/r/autocommit_func.result:
Add a commit (Bug#989).
mysql-test/suite/sys_vars/t/autocommit_func.test:
Add a commit (Bug#989).
mysql-test/t/flush_block_commit.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/t/flush_block_commit_notembedded.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
Add a test case for transaction-scope locks and the global
read lock (Bug#989/WL#4284).
mysql-test/t/innodb.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(effects of Bug#989/WL#4284).
mysql-test/t/lock.test:
Add a test case for Bug#989/WL#4284.
mysql-test/t/not_embedded_server.test:
Add a test case for Bug#989/WL#4284.
mysql-test/t/partition_innodb_semi_consistent.test:
Replace TRUNCATE with DELETE, to not issue
an implicit commit of a transaction, and not depend
on metadata locks.
mysql-test/t/partition_sync.test:
Temporarily disable the test case for Bug#43867,
which needs a fix to be backported from 6.0.
mysql-test/t/ps.test:
Add a test case for semantics of PREPARE and transaction-scope
locks: metadata locks on tables used in PREPARE are enclosed into a
temporary savepoint, taken at the beginning of PREPARE,
and released at the end. Thus PREPARE does not effect
what locks a transaction owns.
mysql-test/t/read_only_innodb.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(Bug#989/WL#4284).
Wait for the read_only statement to actually flush tables before
sending other concurrent statements that depend on its state.
mysql-test/t/xa.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(Bug#989/WL#4284).
sql/ha_ndbcluster_binlog.cc:
Backport bits of changes of ha_ndbcluster_binlog.cc
from 6.0, to fix the failing binlog test suite with
WL#4284. WL#4284 implementation does not work
with 5.1 implementation of ndbcluster binlog index.
sql/log_event.cc:
Release metadata locks after issuing a commit.
sql/mdl.cc:
Style changes (WL#4284).
sql/mysql_priv.h:
Rename parameter to match the name used in the definition (WL#4284).
sql/rpl_injector.cc:
Release metadata locks on commit (WL#4284).
sql/rpl_rli.cc:
Remove assert made meaningless, metadata locks are released
at the end of the transaction.
sql/set_var.cc:
Close tables and release locks if autocommit mode is set.
sql/slave.cc:
Release metadata locks after a rollback.
sql/sql_acl.cc:
Don't implicitly unlock locked tables. Issue a implicit commit
at the end and unlock tables.
sql/sql_base.cc:
Defer the release of metadata locks when closing tables
if not required to.
Issue a deadlock error if the locking protocol requires
that a transaction re-acquire its locks.
Release metadata locks when closing tables for reopen.
sql/sql_class.cc:
Release metadata locks if the thread is killed.
sql/sql_parse.cc:
Release metadata locks after implicitly committing a active
transaction, or after explicit commits or rollbacks.
sql/sql_plugin.cc:
Allocate MDL request on the stack as the use of the table
is contained within the function. It will be removed from
the context once close_thread_tables is called at the end
of the function.
sql/sql_prepare.cc:
The problem is that the prepare phase of the CREATE TABLE
statement takes a exclusive metadata lock lock and this can
cause a self-deadlock the thread already holds a shared lock
on the table being that should be created.
The solution is to make the prepare phase take a shared
metadata lock when preparing a CREATE TABLE statement. The
execution of the statement will still acquire a exclusive
lock, but won't cause any problem as it issues a implicit
commit.
After some discussions with stakeholders it has been decided that
metadata locks acquired during a PREPARE statement must be released
once the statement is prepared even if it is prepared within a multi
statement transaction.
sql/sql_servers.cc:
Don't implicitly unlock locked tables. Issue a implicit commit
at the end and unlock tables.
sql/sql_table.cc:
Close table and release metadata locks after a admin operation.
sql/table.h:
The problem is that the prepare phase of the CREATE TABLE
statement takes a exclusive metadata lock lock and this can
cause a self-deadlock the thread already holds a shared lock
on the table being that should be created.
The solution is to make the prepare phase take a shared
metadata lock when preparing a CREATE TABLE statement. The
execution of the statement will still acquire a exclusive
lock, but won't cause any problem as it issues a implicit
commit.
sql/transaction.cc:
Release metadata locks after the implicitly committed due
to a new transaction being started. Also, release metadata
locks acquired after a savepoint if the transaction is rolled
back to the save point.
The problem is that in some cases transaction-long metadata locks
could be released before the transaction was committed. This could
happen when a active transaction was ended by a "START TRANSACTION"
or "BEGIN" statement, in which case the metadata locks would be
released before the actual commit of the active transaction.
The solution is to defer the release of metadata locks to after the
transaction has been implicitly committed. No test case is provided
as the effort to provide one is too disproportional to the size of
the fix.
2009-12-05 00:02:48 +01:00
|
|
|
{
|
2012-08-24 10:17:08 +02:00
|
|
|
char buf1[NAME_CHAR_LEN + 3];
|
2009-12-22 10:35:56 +01:00
|
|
|
strxnmov(buf1, sizeof(buf1)-1, "@@", name.str, 0);
|
2012-08-24 10:17:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
if deprecation_substitute is an empty string,
|
|
|
|
there is no replacement for the syntax
|
|
|
|
*/
|
|
|
|
uint errmsg= deprecation_substitute[0] == '\0'
|
|
|
|
? ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT
|
|
|
|
: ER_WARN_DEPRECATED_SYNTAX;
|
2009-12-22 10:35:56 +01:00
|
|
|
if (thd)
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_WARN_DEPRECATED_SYNTAX, ER_THD(thd, errmsg),
|
2012-08-24 10:17:08 +02:00
|
|
|
buf1, deprecation_substitute);
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
2012-08-24 10:17:08 +02:00
|
|
|
sql_print_warning(ER_DEFAULT(errmsg), buf1, deprecation_substitute);
|
Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5,
2617.31.12, 2617.31.15, 2617.31.15, 2617.31.16, 2617.43.1
- initial changeset that introduced the fix for
Bug#989 and follow up fixes for all test suite failures
introduced in the initial changeset.
------------------------------------------------------------
revno: 2617.31.1
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: 4284-6.0
timestamp: Fri 2009-03-06 19:17:00 -0300
message:
Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order
WL#4284: Transactional DDL locking
Currently the MySQL server does not keep metadata locks on
schema objects for the duration of a transaction, thus failing
to guarantee the integrity of the schema objects being used
during the transaction and to protect then from concurrent
DDL operations. This also poses a problem for replication as
a DDL operation might be replicated even thought there are
active transactions using the object being modified.
The solution is to defer the release of metadata locks until
a active transaction is either committed or rolled back. This
prevents other statements from modifying the table for the
entire duration of the transaction. This provides commitment
ordering for guaranteeing serializability across multiple
transactions.
- Incompatible change:
If MySQL's metadata locking system encounters a lock conflict,
the usual schema is to use the try and back-off technique to
avoid deadlocks -- this schema consists in releasing all locks
and trying to acquire them all in one go.
But in a transactional context this algorithm can't be utilized
as its not possible to release locks acquired during the course
of the transaction without breaking the transaction commitments.
To avoid deadlocks in this case, the ER_LOCK_DEADLOCK will be
returned if a lock conflict is encountered during a transaction.
Let's consider an example:
A transaction has two statements that modify table t1, then table
t2, and then commits. The first statement of the transaction will
acquire a shared metadata lock on table t1, and it will be kept
utill COMMIT to ensure serializability.
At the moment when the second statement attempts to acquire a
shared metadata lock on t2, a concurrent ALTER or DROP statement
might have locked t2 exclusively. The prescription of the current
locking protocol is that the acquirer of the shared lock backs off
-- gives up all his current locks and retries. This implies that
the entire multi-statement transaction has to be rolled back.
- Incompatible change:
FLUSH commands such as FLUSH PRIVILEGES and FLUSH TABLES WITH READ
LOCK won't cause locked tables to be implicitly unlocked anymore.
mysql-test/extra/binlog_tests/drop_table.test:
Add test case for Bug#989.
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/include/mix1.inc:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/include/mix2.inc:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/r/flush_block_commit.result:
Update test case result (WL#4284).
mysql-test/r/flush_block_commit_notembedded.result:
Update test case result (WL#4284).
mysql-test/r/innodb.result:
Update test case result (WL#4284).
mysql-test/r/innodb_mysql.result:
Update test case result (WL#4284).
mysql-test/r/lock.result:
Add test case result for an effect of WL#4284/Bug#989
(all locks should be released when a connection terminates).
mysql-test/r/mix2_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/r/not_embedded_server.result:
Update test case result (effects of WL#4284/Bug#989).
Add a test case for interaction of WL#4284 and FLUSH PRIVILEGES.
mysql-test/r/partition_innodb_semi_consistent.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/r/partition_sync.result:
Temporarily disable the test case for Bug#43867,
which will be fixed by a subsequent backport.
mysql-test/r/ps.result:
Add a test case for effect of PREPARE on transactional
locks: we take a savepoint at beginning of PREAPRE
and release it at the end. Thus PREPARE does not
accumulate metadata locks (Bug#989/WL#4284).
mysql-test/r/read_only_innodb.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_row_drop_tbl.result:
Add a test case result (WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_stm_drop_tbl.result:
Add a test case result (WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_unsafe.result:
A side effect of Bug#989 -- slightly different table map ids.
mysql-test/suite/binlog/t/binlog_row_drop_tbl.test:
Add a test case for WL#4284/Bug#989.
mysql-test/suite/binlog/t/binlog_stm_drop_tbl.test:
Add a test case for WL#4284/Bug#989.
mysql-test/suite/binlog/t/binlog_stm_row.test:
Update to the new state name. This
is actually a follow up to another patch for WL#4284,
that changes Locked thread state to Table lock.
mysql-test/suite/ndb/r/ndb_index_ordered.result:
Remove result for disabled part of the test case.
mysql-test/suite/ndb/t/disabled.def:
Temporarily disable a test case (Bug#45621).
mysql-test/suite/ndb/t/ndb_index_ordered.test:
Disable a part of a test case (needs update to
reflect semantics of Bug#989).
mysql-test/suite/rpl/t/disabled.def:
Disable tests made meaningless by transactional metadata
locking.
mysql-test/suite/sys_vars/r/autocommit_func.result:
Add a commit (Bug#989).
mysql-test/suite/sys_vars/t/autocommit_func.test:
Add a commit (Bug#989).
mysql-test/t/flush_block_commit.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/t/flush_block_commit_notembedded.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
Add a test case for transaction-scope locks and the global
read lock (Bug#989/WL#4284).
mysql-test/t/innodb.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(effects of Bug#989/WL#4284).
mysql-test/t/lock.test:
Add a test case for Bug#989/WL#4284.
mysql-test/t/not_embedded_server.test:
Add a test case for Bug#989/WL#4284.
mysql-test/t/partition_innodb_semi_consistent.test:
Replace TRUNCATE with DELETE, to not issue
an implicit commit of a transaction, and not depend
on metadata locks.
mysql-test/t/partition_sync.test:
Temporarily disable the test case for Bug#43867,
which needs a fix to be backported from 6.0.
mysql-test/t/ps.test:
Add a test case for semantics of PREPARE and transaction-scope
locks: metadata locks on tables used in PREPARE are enclosed into a
temporary savepoint, taken at the beginning of PREPARE,
and released at the end. Thus PREPARE does not effect
what locks a transaction owns.
mysql-test/t/read_only_innodb.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(Bug#989/WL#4284).
Wait for the read_only statement to actually flush tables before
sending other concurrent statements that depend on its state.
mysql-test/t/xa.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(Bug#989/WL#4284).
sql/ha_ndbcluster_binlog.cc:
Backport bits of changes of ha_ndbcluster_binlog.cc
from 6.0, to fix the failing binlog test suite with
WL#4284. WL#4284 implementation does not work
with 5.1 implementation of ndbcluster binlog index.
sql/log_event.cc:
Release metadata locks after issuing a commit.
sql/mdl.cc:
Style changes (WL#4284).
sql/mysql_priv.h:
Rename parameter to match the name used in the definition (WL#4284).
sql/rpl_injector.cc:
Release metadata locks on commit (WL#4284).
sql/rpl_rli.cc:
Remove assert made meaningless, metadata locks are released
at the end of the transaction.
sql/set_var.cc:
Close tables and release locks if autocommit mode is set.
sql/slave.cc:
Release metadata locks after a rollback.
sql/sql_acl.cc:
Don't implicitly unlock locked tables. Issue a implicit commit
at the end and unlock tables.
sql/sql_base.cc:
Defer the release of metadata locks when closing tables
if not required to.
Issue a deadlock error if the locking protocol requires
that a transaction re-acquire its locks.
Release metadata locks when closing tables for reopen.
sql/sql_class.cc:
Release metadata locks if the thread is killed.
sql/sql_parse.cc:
Release metadata locks after implicitly committing a active
transaction, or after explicit commits or rollbacks.
sql/sql_plugin.cc:
Allocate MDL request on the stack as the use of the table
is contained within the function. It will be removed from
the context once close_thread_tables is called at the end
of the function.
sql/sql_prepare.cc:
The problem is that the prepare phase of the CREATE TABLE
statement takes a exclusive metadata lock lock and this can
cause a self-deadlock the thread already holds a shared lock
on the table being that should be created.
The solution is to make the prepare phase take a shared
metadata lock when preparing a CREATE TABLE statement. The
execution of the statement will still acquire a exclusive
lock, but won't cause any problem as it issues a implicit
commit.
After some discussions with stakeholders it has been decided that
metadata locks acquired during a PREPARE statement must be released
once the statement is prepared even if it is prepared within a multi
statement transaction.
sql/sql_servers.cc:
Don't implicitly unlock locked tables. Issue a implicit commit
at the end and unlock tables.
sql/sql_table.cc:
Close table and release metadata locks after a admin operation.
sql/table.h:
The problem is that the prepare phase of the CREATE TABLE
statement takes a exclusive metadata lock lock and this can
cause a self-deadlock the thread already holds a shared lock
on the table being that should be created.
The solution is to make the prepare phase take a shared
metadata lock when preparing a CREATE TABLE statement. The
execution of the statement will still acquire a exclusive
lock, but won't cause any problem as it issues a implicit
commit.
sql/transaction.cc:
Release metadata locks after the implicitly committed due
to a new transaction being started. Also, release metadata
locks acquired after a savepoint if the transaction is rolled
back to the save point.
The problem is that in some cases transaction-long metadata locks
could be released before the transaction was committed. This could
happen when a active transaction was ended by a "START TRANSACTION"
or "BEGIN" statement, in which case the metadata locks would be
released before the actual commit of the active transaction.
The solution is to defer the release of metadata locks to after the
transaction has been implicitly committed. No test case is provided
as the effort to provide one is too disproportional to the size of
the fix.
2009-12-05 00:02:48 +01:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2009-09-23 13:20:48 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
Throw warning (error in STRICT mode) if value for variable needed bounding.
|
|
|
|
Plug-in interface also uses this.
|
|
|
|
|
|
|
|
@param thd thread handle
|
|
|
|
@param name variable's name
|
|
|
|
@param fixed did we have to correct the value? (throw warn/err if so)
|
|
|
|
@param is_unsigned is value's type unsigned?
|
|
|
|
@param v variable's value
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
@retval true on error, false otherwise (warning or ok)
|
|
|
|
*/
|
|
|
|
bool throw_bounds_warning(THD *thd, const char *name,
|
|
|
|
bool fixed, bool is_unsigned, longlong v)
|
2004-04-28 12:08:54 +02:00
|
|
|
{
|
2011-11-22 18:05:34 +01:00
|
|
|
if (fixed)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
char buf[22];
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
if (is_unsigned)
|
|
|
|
ullstr((ulonglong) v, buf);
|
2002-07-23 17:31:22 +02:00
|
|
|
else
|
2009-12-22 10:35:56 +01:00
|
|
|
llstr(v, buf);
|
2006-03-01 21:36:05 +01:00
|
|
|
|
2017-01-31 18:34:38 +01:00
|
|
|
if (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buf);
|
|
|
|
return true;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2009-12-22 10:35:56 +01:00
|
|
|
ER_TRUNCATED_WRONG_VALUE,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), name, buf);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
return false;
|
2004-04-28 12:08:54 +02:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
bool throw_bounds_warning(THD *thd, const char *name, bool fixed, double v)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
if (fixed)
|
2003-04-02 00:15:20 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
char buf[64];
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-28 13:54:16 +01:00
|
|
|
my_gcvt(v, MY_GCVT_ARG_DOUBLE, sizeof(buf) - 1, buf, NULL);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2017-01-31 18:34:38 +01:00
|
|
|
if (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES)
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buf);
|
|
|
|
return true;
|
|
|
|
}
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2009-12-22 10:35:56 +01:00
|
|
|
ER_TRUNCATED_WRONG_VALUE,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), name, buf);
|
2004-04-28 12:08:54 +02:00
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
return false;
|
2004-04-28 12:08:54 +02:00
|
|
|
}
|
2003-04-02 00:15:20 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
CHARSET_INFO *sys_var::charset(THD *thd)
|
2002-10-02 12:33:08 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
return is_os_charset ? thd->variables.character_set_filesystem :
|
|
|
|
system_charset_info;
|
2002-10-02 12:33:08 +02:00
|
|
|
}
|
|
|
|
|
2014-09-03 20:16:51 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
typedef struct old_names_map_st
|
2002-10-02 12:33:08 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
const char *old_name;
|
|
|
|
const char *new_name;
|
|
|
|
} my_old_conv;
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
include/sslopt-longopts.h:
Put options in alphabetical order
include/sslopt-vars.h:
Allow define of SSL_VARS_NOT_STATIC to prevent variables from not being
made static.
mysql-test/r/variables.result:
Add new results
mysql-test/t/variables.test:
Add new regression tests
sql/mysql_priv.h:
Add extern for opt_log_queries_not_using_indexes
sql/mysqld.cc:
Handle opt_log_queries_not_using_indexes as extern, and define
SSL_VARS_NO_STATIC so they can be accessed outside of mysqld.cc
sql/set_var.cc:
Handle basedir, datadir, tmpdir, log_queries_not_using_indexes, and
various ssl settings so that they are accessible as server variables
and listed in SHOW VARIABLES.
sql/set_var.h:
Add new sys_var_constr_str_ptr class, for when we have a system variable
that is only set via the command-line that is a pointer to a string.
2006-05-09 01:38:45 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
static my_old_conv old_conv[]=
|
|
|
|
{
|
|
|
|
{ "cp1251_koi8" , "cp1251" },
|
|
|
|
{ "cp1250_latin2" , "cp1250" },
|
|
|
|
{ "kam_latin2" , "keybcs2" },
|
|
|
|
{ "mac_latin2" , "MacRoman" },
|
|
|
|
{ "macce_latin2" , "MacCE" },
|
|
|
|
{ "pc2_latin2" , "pclatin2" },
|
|
|
|
{ "vga_latin2" , "pclatin1" },
|
|
|
|
{ "koi8_cp1251" , "koi8r" },
|
|
|
|
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
|
|
|
|
{ "koi8_ukr_win1251ukr" , "koi8u" },
|
|
|
|
{ NULL , NULL }
|
|
|
|
};
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
include/sslopt-longopts.h:
Put options in alphabetical order
include/sslopt-vars.h:
Allow define of SSL_VARS_NOT_STATIC to prevent variables from not being
made static.
mysql-test/r/variables.result:
Add new results
mysql-test/t/variables.test:
Add new regression tests
sql/mysql_priv.h:
Add extern for opt_log_queries_not_using_indexes
sql/mysqld.cc:
Handle opt_log_queries_not_using_indexes as extern, and define
SSL_VARS_NO_STATIC so they can be accessed outside of mysqld.cc
sql/set_var.cc:
Handle basedir, datadir, tmpdir, log_queries_not_using_indexes, and
various ssl settings so that they are accessible as server variables
and listed in SHOW VARIABLES.
sql/set_var.h:
Add new sys_var_constr_str_ptr class, for when we have a system variable
that is only set via the command-line that is a pointer to a string.
2006-05-09 01:38:45 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
CHARSET_INFO *get_old_charset_by_name(const char *name)
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
include/sslopt-longopts.h:
Put options in alphabetical order
include/sslopt-vars.h:
Allow define of SSL_VARS_NOT_STATIC to prevent variables from not being
made static.
mysql-test/r/variables.result:
Add new results
mysql-test/t/variables.test:
Add new regression tests
sql/mysql_priv.h:
Add extern for opt_log_queries_not_using_indexes
sql/mysqld.cc:
Handle opt_log_queries_not_using_indexes as extern, and define
SSL_VARS_NO_STATIC so they can be accessed outside of mysqld.cc
sql/set_var.cc:
Handle basedir, datadir, tmpdir, log_queries_not_using_indexes, and
various ssl settings so that they are accessible as server variables
and listed in SHOW VARIABLES.
sql/set_var.h:
Add new sys_var_constr_str_ptr class, for when we have a system variable
that is only set via the command-line that is a pointer to a string.
2006-05-09 01:38:45 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_old_conv *conv;
|
Bug #1039: tmpdir and datadir not available via @@ system variable syntax
Bug #19606: ssl variables are not displayed in show variables
Bug #19616: log_queries_not_using_indexes is not listed in show variables
Make basedir, datadir, tmpdir, log_queries_not_using_indexes, ssl_ca,
ssl_capath, ssl_cert, ssl_cipher, and ssl_key all available both from
SHOW VARIABLES and as @@variables.
As a side-effect of this change, log_queries_not_using_indexes can
be changed at runtime (but only globally, not per-connection).
include/sslopt-longopts.h:
Put options in alphabetical order
include/sslopt-vars.h:
Allow define of SSL_VARS_NOT_STATIC to prevent variables from not being
made static.
mysql-test/r/variables.result:
Add new results
mysql-test/t/variables.test:
Add new regression tests
sql/mysql_priv.h:
Add extern for opt_log_queries_not_using_indexes
sql/mysqld.cc:
Handle opt_log_queries_not_using_indexes as extern, and define
SSL_VARS_NO_STATIC so they can be accessed outside of mysqld.cc
sql/set_var.cc:
Handle basedir, datadir, tmpdir, log_queries_not_using_indexes, and
various ssl settings so that they are accessible as server variables
and listed in SHOW VARIABLES.
sql/set_var.h:
Add new sys_var_constr_str_ptr class, for when we have a system variable
that is only set via the command-line that is a pointer to a string.
2006-05-09 01:38:45 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
for (conv= old_conv; conv->old_name; conv++)
|
|
|
|
{
|
|
|
|
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
|
|
|
|
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
|
|
|
|
}
|
|
|
|
return NULL;
|
2009-12-17 12:25:50 +01:00
|
|
|
}
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Main handling of variables:
|
|
|
|
- Initialisation
|
|
|
|
- Searching during parsing
|
|
|
|
- Update loop
|
|
|
|
****************************************************************************/
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
2009-12-22 10:35:56 +01:00
|
|
|
Add variables to the dynamic hash of system variables
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
@param first Pointer to first system variable to add
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2007-03-02 17:43:45 +01:00
|
|
|
0 SUCCESS
|
2009-12-22 10:35:56 +01:00
|
|
|
@retval
|
2007-03-02 17:43:45 +01:00
|
|
|
otherwise FAILURE
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
int mysql_add_sys_var_chain(sys_var *first)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2005-11-06 01:36:40 +01:00
|
|
|
sys_var *var;
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/* A write lock should be held on LOCK_system_variables_hash */
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
for (var= first; var; var= var->next)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
/* this fails if there is a conflicting variable name. see HASH_UNIQUE */
|
2007-05-24 12:24:36 +02:00
|
|
|
if (my_hash_insert(&system_variable_hash, (uchar*) var))
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "*** duplicate variable name '%s' ?\n", var->name.str);
|
2007-03-02 17:43:45 +01:00
|
|
|
goto error;
|
2009-12-22 10:35:56 +01:00
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
for (; first != var; first= first->next)
|
2009-10-14 18:37:38 +02:00
|
|
|
my_hash_delete(&system_variable_hash, (uchar*) first);
|
2007-03-02 17:43:45 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
Remove variables to the dynamic hash of system variables
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
SYNOPSIS
|
|
|
|
mysql_del_sys_var_chain()
|
|
|
|
first Pointer to first system variable to remove
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
RETURN VALUES
|
|
|
|
0 SUCCESS
|
|
|
|
otherwise FAILURE
|
|
|
|
*/
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
int mysql_del_sys_var_chain(sys_var *first)
|
|
|
|
{
|
|
|
|
int result= 0;
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2014-01-28 08:12:43 +01:00
|
|
|
mysql_rwlock_wrlock(&LOCK_system_variables_hash);
|
2007-03-02 17:43:45 +01:00
|
|
|
for (sys_var *var= first; var; var= var->next)
|
2009-10-14 18:37:38 +02:00
|
|
|
result|= my_hash_delete(&system_variable_hash, (uchar*) var);
|
2014-01-28 08:12:43 +01:00
|
|
|
mysql_rwlock_unlock(&LOCK_system_variables_hash);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static int show_cmp(SHOW_VAR *a, SHOW_VAR *b)
|
|
|
|
{
|
|
|
|
return strcmp(a->name, b->name);
|
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-03-02 17:43:45 +01:00
|
|
|
Constructs an array of system variables for display to the user.
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
@param thd current thread
|
|
|
|
@param sorted If TRUE, the system variables should be sorted
|
2014-08-29 13:59:08 +02:00
|
|
|
@param scope OPT_GLOBAL or OPT_SESSION for SHOW GLOBAL|SESSION VARIABLES
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
@retval
|
2007-03-02 17:43:45 +01:00
|
|
|
pointer Array of SHOW_VAR elements for display
|
2009-12-22 10:35:56 +01:00
|
|
|
@retval
|
2007-03-02 17:43:45 +01:00
|
|
|
NULL FAILURE
|
|
|
|
*/
|
|
|
|
|
2014-08-29 13:59:08 +02:00
|
|
|
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted, enum enum_var_type scope)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
int count= system_variable_hash.records, i;
|
2008-11-22 00:22:21 +01:00
|
|
|
int size= sizeof(SHOW_VAR) * (count + 1);
|
2007-03-02 17:43:45 +01:00
|
|
|
SHOW_VAR *result= (SHOW_VAR*) thd->alloc(size);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
2008-11-22 00:22:21 +01:00
|
|
|
SHOW_VAR *show= result;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
for (i= 0; i < count; i++)
|
|
|
|
{
|
2009-10-14 18:37:38 +02:00
|
|
|
sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
// don't show session-only variables in SHOW GLOBAL VARIABLES
|
2014-08-29 13:59:08 +02:00
|
|
|
if (scope == OPT_GLOBAL && var->check_type(scope))
|
2009-12-22 10:35:56 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
show->name= var->name.str;
|
2007-03-02 17:43:45 +01:00
|
|
|
show->value= (char*) var;
|
|
|
|
show->type= SHOW_SYS;
|
|
|
|
show++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sort into order */
|
|
|
|
if (sorted)
|
2009-12-22 10:35:56 +01:00
|
|
|
my_qsort(result, show-result, sizeof(SHOW_VAR),
|
2007-10-18 13:17:21 +02:00
|
|
|
(qsort_cmp) show_cmp);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/* make last element empty */
|
|
|
|
bzero(show, sizeof(SHOW_VAR));
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Find a user set-table variable.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
@param str Name of system variable to find
|
2007-10-11 20:37:45 +02:00
|
|
|
@param length Length of variable. zero means that we should use strlen()
|
|
|
|
on the variable
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
pointer pointer to variable definitions
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
0 Unknown variable (error message is given)
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
sys_var *intern_find_sys_var(const char *str, uint length)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var *var;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function is only called from the sql_plugin.cc.
|
|
|
|
A lock on LOCK_system_variable_hash should be held
|
|
|
|
*/
|
2009-10-14 18:37:38 +02:00
|
|
|
var= (sys_var*) my_hash_search(&system_variable_hash,
|
2009-12-22 10:35:56 +01:00
|
|
|
(uchar*) str, length ? length : strlen(str));
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-08 14:42:01 +02:00
|
|
|
bool find_sys_var_null_base(THD *thd, struct sys_var_with_base *tmp)
|
|
|
|
{
|
|
|
|
tmp->var= find_sys_var(thd, tmp->base_name.str, tmp->base_name.length);
|
|
|
|
|
|
|
|
if (tmp->var != NULL)
|
2017-04-23 18:39:57 +02:00
|
|
|
tmp->base_name= null_clex_str;
|
2016-08-08 14:42:01 +02:00
|
|
|
|
|
|
|
return thd->is_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Execute update of all variables.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
First run a check of all variables that all updates will go ok.
|
|
|
|
If yes, then execute all updates, returning an error if any one failed.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
This should ensure that in all normal cases none all or variables are
|
|
|
|
updated.
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
@param THD Thread id
|
2007-10-11 20:37:45 +02:00
|
|
|
@param var_list List of variables to update
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
0 ok
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
1 ERROR, message sent (normally no variables was updated)
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2002-09-22 17:02:39 +02:00
|
|
|
-1 ERROR, message not sent
|
2002-07-23 17:31:22 +02:00
|
|
|
*/
|
|
|
|
|
2014-10-24 10:13:08 +02:00
|
|
|
int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool free)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2014-10-24 10:13:08 +02:00
|
|
|
int error= 0;
|
|
|
|
bool was_error= thd->is_error();
|
2003-05-27 17:40:37 +02:00
|
|
|
List_iterator_fast<set_var_base> it(*var_list);
|
2003-08-18 23:08:08 +02:00
|
|
|
DBUG_ENTER("sql_set_variables");
|
2002-07-23 17:31:22 +02:00
|
|
|
|
|
|
|
set_var_base *var;
|
|
|
|
while ((var=it++))
|
|
|
|
{
|
2004-12-02 13:43:51 +01:00
|
|
|
if ((error= var->check(thd)))
|
2004-11-22 11:05:10 +01:00
|
|
|
goto err;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2014-10-24 10:13:08 +02:00
|
|
|
if (was_error || !(error= MY_TEST(thd->is_error())))
|
Implementation of WL#1824 "Add replication of character set variables in 4.1",
by binlogging some SET ONE_SHOT CHARACTER_SETetc,
which will be enough until we have it more compact and more complete in 5.0. With the present patch,
replication will work ok between 4.1.3 master and slaves, as long as:
- master and slave have the same GLOBAL.COLLATION_SERVER
- COLLATION_DATABASE and CHARACTER_SET_DATABASE are not used
- application does not use the fact that table is created with charset of the USEd db (BUG#2326).
all of which are not too hard to fulfill.
ONE_SHOT is reserved for internal use of mysqlbinlog|mysql and works only for charsets,
so we give error if used for non-charset vars.
Fix for BUG#3875 "mysqlbinlog produces wrong ouput if query uses
variables containing quotes" and BUG#3943 "Queries with non-ASCII literals are not replicated
properly after SET NAMES".
Detecting that master and slave have different global charsets or server ids.
mysql-test/r/rpl_server_id1.result:
it's normal to not run as I have added a test to compare server ids of master and slave
at startup and stop if equal (unless --replicate-same-server-id)
mysql-test/r/rpl_user_variables.result:
result update (as we now print charset of user var).
mysql-test/r/user_var.result:
result update
mysql-test/t/rpl_server_id1.test:
no need to select as slave is not running
mysql-test/t/user_var.test:
testing if the content of user vars is escaped when mysqlbinlog prints them,
and if the name is backquoted.
sql/lex.h:
new keyword ONE_SHOT
sql/log.cc:
when writing to the binlog, before writing the actual statement, write some SET ONE_SHOT CHARACTER_SET_CLIENT etc
for the slave to know the charset variables (which are important as they affect the inserted data).
sql/log_event.cc:
print charset and collation of user var in mysqlbinlog and SHOW BINLOG EVENTS.
escape the content of the var. Backquote its name.
Will ask Bar to check that using my_charset_bin for escaping is ok.
sql/set_var.cc:
understand SET CHARACTER_SET_CLIENT=10 (don't require a string, accept a number).
Refuse changing of GLOBAL CHARACTER_SET_SERVER/COLLATION_SERVER if binlog or slave,
as it will make the master or slave make wrong assumptions.
A function to catch SET ONE_SHOT on non-charset variables (which is forbidden)
sql/set_var.h:
no_support_one_shot to know if the var supports ONE_SHOT (only charset vars do, soon timezones).
Accept int arg in SET CHARACTER_SET_etc
sql/slave.cc:
when I/O slave thread starts, verify that master's and slave charsets match.
And by the way verify that server ids are different.
Don't fail if UNIX_TIMESTAMP() can't be done on master (very old master), that's
not fatal.
sql/sql_class.cc:
one_shot
sql/sql_class.h:
one_shot
sql/sql_lex.h:
one_shot
sql/sql_parse.cc:
when SET ONE_SHOT is used, verify that it's only used for charset/collation vars;
otherwise refuse.
sql/sql_yacc.yy:
ONE_SHOT keyword in SET
2004-06-03 23:17:18 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
it.rewind();
|
|
|
|
while ((var= it++))
|
|
|
|
error|= var->update(thd); // Returns 0, -1 or 1
|
Implementation of WL#1824 "Add replication of character set variables in 4.1",
by binlogging some SET ONE_SHOT CHARACTER_SETetc,
which will be enough until we have it more compact and more complete in 5.0. With the present patch,
replication will work ok between 4.1.3 master and slaves, as long as:
- master and slave have the same GLOBAL.COLLATION_SERVER
- COLLATION_DATABASE and CHARACTER_SET_DATABASE are not used
- application does not use the fact that table is created with charset of the USEd db (BUG#2326).
all of which are not too hard to fulfill.
ONE_SHOT is reserved for internal use of mysqlbinlog|mysql and works only for charsets,
so we give error if used for non-charset vars.
Fix for BUG#3875 "mysqlbinlog produces wrong ouput if query uses
variables containing quotes" and BUG#3943 "Queries with non-ASCII literals are not replicated
properly after SET NAMES".
Detecting that master and slave have different global charsets or server ids.
mysql-test/r/rpl_server_id1.result:
it's normal to not run as I have added a test to compare server ids of master and slave
at startup and stop if equal (unless --replicate-same-server-id)
mysql-test/r/rpl_user_variables.result:
result update (as we now print charset of user var).
mysql-test/r/user_var.result:
result update
mysql-test/t/rpl_server_id1.test:
no need to select as slave is not running
mysql-test/t/user_var.test:
testing if the content of user vars is escaped when mysqlbinlog prints them,
and if the name is backquoted.
sql/lex.h:
new keyword ONE_SHOT
sql/log.cc:
when writing to the binlog, before writing the actual statement, write some SET ONE_SHOT CHARACTER_SET_CLIENT etc
for the slave to know the charset variables (which are important as they affect the inserted data).
sql/log_event.cc:
print charset and collation of user var in mysqlbinlog and SHOW BINLOG EVENTS.
escape the content of the var. Backquote its name.
Will ask Bar to check that using my_charset_bin for escaping is ok.
sql/set_var.cc:
understand SET CHARACTER_SET_CLIENT=10 (don't require a string, accept a number).
Refuse changing of GLOBAL CHARACTER_SET_SERVER/COLLATION_SERVER if binlog or slave,
as it will make the master or slave make wrong assumptions.
A function to catch SET ONE_SHOT on non-charset variables (which is forbidden)
sql/set_var.h:
no_support_one_shot to know if the var supports ONE_SHOT (only charset vars do, soon timezones).
Accept int arg in SET CHARACTER_SET_etc
sql/slave.cc:
when I/O slave thread starts, verify that master's and slave charsets match.
And by the way verify that server ids are different.
Don't fail if UNIX_TIMESTAMP() can't be done on master (very old master), that's
not fatal.
sql/sql_class.cc:
one_shot
sql/sql_class.h:
one_shot
sql/sql_lex.h:
one_shot
sql/sql_parse.cc:
when SET ONE_SHOT is used, verify that it's only used for charset/collation vars;
otherwise refuse.
sql/sql_yacc.yy:
ONE_SHOT keyword in SET
2004-06-03 23:17:18 +02:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
err:
|
2014-10-24 10:13:08 +02:00
|
|
|
if (free)
|
|
|
|
free_underlaid_joins(thd, &thd->lex->select_lex);
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_RETURN(error);
|
|
|
|
}
|
Implementation of WL#1824 "Add replication of character set variables in 4.1",
by binlogging some SET ONE_SHOT CHARACTER_SETetc,
which will be enough until we have it more compact and more complete in 5.0. With the present patch,
replication will work ok between 4.1.3 master and slaves, as long as:
- master and slave have the same GLOBAL.COLLATION_SERVER
- COLLATION_DATABASE and CHARACTER_SET_DATABASE are not used
- application does not use the fact that table is created with charset of the USEd db (BUG#2326).
all of which are not too hard to fulfill.
ONE_SHOT is reserved for internal use of mysqlbinlog|mysql and works only for charsets,
so we give error if used for non-charset vars.
Fix for BUG#3875 "mysqlbinlog produces wrong ouput if query uses
variables containing quotes" and BUG#3943 "Queries with non-ASCII literals are not replicated
properly after SET NAMES".
Detecting that master and slave have different global charsets or server ids.
mysql-test/r/rpl_server_id1.result:
it's normal to not run as I have added a test to compare server ids of master and slave
at startup and stop if equal (unless --replicate-same-server-id)
mysql-test/r/rpl_user_variables.result:
result update (as we now print charset of user var).
mysql-test/r/user_var.result:
result update
mysql-test/t/rpl_server_id1.test:
no need to select as slave is not running
mysql-test/t/user_var.test:
testing if the content of user vars is escaped when mysqlbinlog prints them,
and if the name is backquoted.
sql/lex.h:
new keyword ONE_SHOT
sql/log.cc:
when writing to the binlog, before writing the actual statement, write some SET ONE_SHOT CHARACTER_SET_CLIENT etc
for the slave to know the charset variables (which are important as they affect the inserted data).
sql/log_event.cc:
print charset and collation of user var in mysqlbinlog and SHOW BINLOG EVENTS.
escape the content of the var. Backquote its name.
Will ask Bar to check that using my_charset_bin for escaping is ok.
sql/set_var.cc:
understand SET CHARACTER_SET_CLIENT=10 (don't require a string, accept a number).
Refuse changing of GLOBAL CHARACTER_SET_SERVER/COLLATION_SERVER if binlog or slave,
as it will make the master or slave make wrong assumptions.
A function to catch SET ONE_SHOT on non-charset variables (which is forbidden)
sql/set_var.h:
no_support_one_shot to know if the var supports ONE_SHOT (only charset vars do, soon timezones).
Accept int arg in SET CHARACTER_SET_etc
sql/slave.cc:
when I/O slave thread starts, verify that master's and slave charsets match.
And by the way verify that server ids are different.
Don't fail if UNIX_TIMESTAMP() can't be done on master (very old master), that's
not fatal.
sql/sql_class.cc:
one_shot
sql/sql_class.h:
one_shot
sql/sql_lex.h:
one_shot
sql/sql_parse.cc:
when SET ONE_SHOT is used, verify that it's only used for charset/collation vars;
otherwise refuse.
sql/sql_yacc.yy:
ONE_SHOT keyword in SET
2004-06-03 23:17:18 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET mysql_internal_variable=const_expr
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-10-29 12:19:36 +01:00
|
|
|
/**
|
|
|
|
Verify that the supplied value is correct.
|
|
|
|
|
|
|
|
@param thd Thread handler
|
|
|
|
|
|
|
|
@return status code
|
2009-12-22 10:35:56 +01:00
|
|
|
@retval -1 Failure
|
|
|
|
@retval 0 Success
|
|
|
|
*/
|
2009-10-29 12:19:36 +01:00
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var::check(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2013-09-05 10:10:27 +02:00
|
|
|
var->do_deprecated_warning(thd);
|
2005-05-13 13:18:27 +02:00
|
|
|
if (var->is_readonly())
|
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->name.str, "read only");
|
2005-05-13 13:18:27 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
if (var->check_type(type))
|
|
|
|
{
|
2004-11-12 13:34:00 +01:00
|
|
|
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
|
2009-12-22 10:35:56 +01:00
|
|
|
my_error(err, MYF(0), var->name.str);
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
if ((type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL)))
|
|
|
|
return 1;
|
|
|
|
/* value is a NULL pointer if we are using SET ... = DEFAULT */
|
|
|
|
if (!value)
|
|
|
|
return 0;
|
|
|
|
|
2005-02-08 23:50:45 +01:00
|
|
|
if ((!value->fixed &&
|
2005-07-01 06:05:42 +02:00
|
|
|
value->fix_fields(thd, &value)) || value->check_cols(1))
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2016-03-21 21:09:04 +01:00
|
|
|
if (var->check_update_type(value))
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name.str);
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2003-10-06 14:11:16 +02:00
|
|
|
}
|
2002-09-22 17:02:39 +02:00
|
|
|
return var->check(thd, this) ? -1 : 0;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Check variable, but without assigning value (used by PS).
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
@param thd thread handler
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
0 ok
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
1 ERROR, message sent (normally no variables was updated)
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
-1 ERROR, message not sent
|
2004-04-10 00:14:32 +02:00
|
|
|
*/
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
int set_var::light_check(THD *thd)
|
|
|
|
{
|
|
|
|
if (var->check_type(type))
|
|
|
|
{
|
2004-11-12 13:34:00 +01:00
|
|
|
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
|
now my_printf_error is not better then my_error, but my_error call is shorter
used only one implementation of format parser of (printf)
fixed multistatement
include/mysqld_error.h:
newerror messages
mysql-test/t/key.test:
unknown error replaced with real error
mysys/my_error.c:
my_error & my_printf_error use my_vsprintf
sql/field_conv.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/ha_innodb.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_cmpfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_func.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/item_strfunc.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/lock.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/log.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/parse_file.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/procedure.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/protocol.cc:
no need reset thd->lex->found_colon to break multiline sequance now, send_error called too late
sql/repl_failsafe.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/set_var.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/share/czech/errmsg.txt:
new errors converted from unknown error
sql/share/danish/errmsg.txt:
new errors converted from unknown error
sql/share/dutch/errmsg.txt:
new errors converted from unknown error
sql/share/english/errmsg.txt:
new errors converted from unknown error
sql/share/estonian/errmsg.txt:
new errors converted from unknown error
sql/share/french/errmsg.txt:
new errors converted from unknown error
sql/share/german/errmsg.txt:
new errors converted from unknown error
sql/share/greek/errmsg.txt:
new errors converted from unknown error
sql/share/hungarian/errmsg.txt:
new errors converted from unknown error
sql/share/italian/errmsg.txt:
new errors converted from unknown error
sql/share/japanese/errmsg.txt:
new errors converted from unknown error
sql/share/korean/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian-ny/errmsg.txt:
new errors converted from unknown error
sql/share/norwegian/errmsg.txt:
new errors converted from unknown error
sql/share/polish/errmsg.txt:
new errors converted from unknown error
sql/share/portuguese/errmsg.txt:
new errors converted from unknown error
sql/share/romanian/errmsg.txt:
new errors converted from unknown error
sql/share/russian/errmsg.txt:
new errors converted from unknown error
sql/share/serbian/errmsg.txt:
new errors converted from unknown error
sql/share/slovak/errmsg.txt:
new errors converted from unknown error
sql/share/spanish/errmsg.txt:
new errors converted from unknown error
sql/share/swedish/errmsg.txt:
new errors converted from unknown error
sql/share/ukrainian/errmsg.txt:
new errors converted from unknown error
sql/slave.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sp_head.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_acl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_analyse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_base.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_class.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_db.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_delete.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_handler.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_insert.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_load.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_map.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_parse.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
multi-row command fixed
sql/sql_prepare.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
remover send_error ingected from 4.1
sql/sql_rename.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_repl.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_select.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_show.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_trigger.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_udf.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_update.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_view.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/sql_yacc.yy:
now my_printf_error is not better then my_error, but my_error call is shorter
sql/table.cc:
now my_printf_error is not better then my_error, but my_error call is shorter
strings/my_vsnprintf.c:
* format support added to my_vsprint
2004-11-13 18:35:51 +01:00
|
|
|
my_error(err, MYF(0), var->name);
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2004-04-10 00:14:32 +02:00
|
|
|
if (type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL))
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
return 1;
|
|
|
|
|
2005-07-01 06:05:42 +02:00
|
|
|
if (value && ((!value->fixed && value->fix_fields(thd, &value)) ||
|
2004-12-14 01:36:19 +01:00
|
|
|
value->check_cols(1)))
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-12 11:14:59 +01:00
|
|
|
/**
|
|
|
|
Update variable
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
|
2007-12-12 11:14:59 +01:00
|
|
|
@param thd thread handler
|
2009-12-22 10:35:56 +01:00
|
|
|
@returns 0|1 ok or ERROR
|
2007-12-12 11:14:59 +01:00
|
|
|
|
|
|
|
@note ERROR can be only due to abnormal operations involving
|
|
|
|
the server's execution evironment such as
|
|
|
|
out of memory, hard disk failure or the computer blows up.
|
|
|
|
Consider set_var::check() method if there is a need to return
|
|
|
|
an error due to logics.
|
|
|
|
*/
|
2015-08-20 14:24:13 +02:00
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var::update(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2013-02-25 05:58:25 +01:00
|
|
|
return value ? var->update(thd, this) : var->set_default(thd, this);
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-20 14:24:13 +02:00
|
|
|
set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
|
2017-04-23 18:39:57 +02:00
|
|
|
const LEX_CSTRING *base_name_arg, Item *value_arg)
|
2015-08-20 14:24:13 +02:00
|
|
|
:var(var_arg), type(type_arg), base(*base_name_arg)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
If the set value is a field, change it to a string to allow things like
|
|
|
|
SET table_type=MYISAM;
|
|
|
|
*/
|
|
|
|
if (value_arg && value_arg->type() == Item::FIELD_ITEM)
|
|
|
|
{
|
|
|
|
Item_field *item= (Item_field*) value_arg;
|
|
|
|
// names are utf8
|
2017-04-23 18:39:57 +02:00
|
|
|
if (!(value= new (thd->mem_root) Item_string_sys(thd,
|
|
|
|
item->field_name.str,
|
|
|
|
item->field_name.length)))
|
2015-08-20 14:24:13 +02:00
|
|
|
value=value_arg; /* Give error message later */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
value=value_arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET @user_variable=const_expr
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_user::check(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-11-02 16:27:35 +01:00
|
|
|
/*
|
|
|
|
Item_func_set_user_var can't substitute something else on its place =>
|
2004-04-28 12:08:54 +02:00
|
|
|
0 can be passed as last argument (reference on item)
|
2003-11-02 16:27:35 +01:00
|
|
|
*/
|
2005-07-01 06:05:42 +02:00
|
|
|
return (user_var_item->fix_fields(thd, (Item**) 0) ||
|
2009-12-22 10:35:56 +01:00
|
|
|
user_var_item->check(0)) ? -1 : 0;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
/**
|
|
|
|
Check variable, but without assigning value (used by PS).
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
@param thd thread handler
|
2004-04-10 00:14:32 +02:00
|
|
|
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
0 ok
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
2009-12-22 10:35:56 +01:00
|
|
|
1 ERROR, message sent (normally no variables was updated)
|
2007-10-11 20:37:45 +02:00
|
|
|
@retval
|
|
|
|
-1 ERROR, message not sent
|
2004-04-10 00:14:32 +02:00
|
|
|
*/
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
int set_var_user::light_check(THD *thd)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Item_func_set_user_var can't substitute something else on its place =>
|
|
|
|
0 can be passed as last argument (reference on item)
|
|
|
|
*/
|
2005-07-01 06:05:42 +02:00
|
|
|
return (user_var_item->fix_fields(thd, (Item**) 0));
|
new error for unsupported command in PS
fixed IN subselect with basic constant left expression
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
unchecked commands now is rejected by PS protocol to avoid serever crash
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
include/mysqld_error.h:
new error for unsupported command in PS
mysql-test/r/multi_update.result:
test sutes (BUG#3408, BUG#3411)
mysql-test/t/multi_update.test:
test sutes (BUG#3408, BUG#3411)
sql/item_cmpfunc.cc:
fixed IN subselect with basic constant left expression
sql/mysql_priv.h:
some function frop sql_parse.h become public
sql/set_var.cc:
check for SET command via PS
sql/set_var.h:
check for SET command via PS
sql/share/czech/errmsg.txt:
new error for unsupported command in PS
sql/share/danish/errmsg.txt:
new error for unsupported command in PS
sql/share/dutch/errmsg.txt:
new error for unsupported command in PS
sql/share/english/errmsg.txt:
new error for unsupported command in PS
sql/share/estonian/errmsg.txt:
new error for unsupported command in PS
sql/share/french/errmsg.txt:
new error for unsupported command in PS
sql/share/german/errmsg.txt:
new error for unsupported command in PS
sql/share/greek/errmsg.txt:
new error for unsupported command in PS
sql/share/hungarian/errmsg.txt:
new error for unsupported command in PS
sql/share/italian/errmsg.txt:
new error for unsupported command in PS
sql/share/japanese/errmsg.txt:
new error for unsupported command in PS
sql/share/korean/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian-ny/errmsg.txt:
new error for unsupported command in PS
sql/share/norwegian/errmsg.txt:
new error for unsupported command in PS
sql/share/polish/errmsg.txt:
new error for unsupported command in PS
sql/share/portuguese/errmsg.txt:
new error for unsupported command in PS
sql/share/romanian/errmsg.txt:
new error for unsupported command in PS
sql/share/russian/errmsg.txt:
new error for unsupported command in PS
sql/share/serbian/errmsg.txt:
new error for unsupported command in PS
sql/share/slovak/errmsg.txt:
new error for unsupported command in PS
sql/share/spanish/errmsg.txt:
new error for unsupported command in PS
sql/share/swedish/errmsg.txt:
new error for unsupported command in PS
sql/share/ukrainian/errmsg.txt:
new error for unsupported command in PS
sql/sql_lex.cc:
first table unlincking procedures for CREATE command
sql/sql_lex.h:
first table unlincking procedures for CREATE command
sql/sql_parse.cc:
used function to exclude first table from list
SQLCOM_CREATE_TABLE, SQLCOM_UPDATE_MULTI, SQLCOM_REPLACE_SELECT, SQLCOM_INSERT_SELECT, QLCOM_DELETE_MULTI fixed to be compatible with PS (BUG#3398, BUG#3406)
fixed multiupdate privelege check (BUG#3408)
fixed multiupdate tables check (BUG#3411)
sql/sql_prepare.cc:
fixed a lot of commands to be compatible with PS
unchecked commands now is rejected to avoid serever crash
sql/sql_select.cc:
allow empty result for PS preparing
sql/sql_union.cc:
fixed cleunup procedure to be compatible sith DO/SET (BUG#3393)
sql/sql_update.cc:
fixed update to use correct tables lists (BUG#3408)
sql/table.h:
flag to support multi update tables check (BUG#3408)
tests/client_test.c:
removed unsupported tables
fixed show table test
added new tests
2004-04-07 23:16:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_user::update(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
|
|
|
if (user_var_item->update())
|
|
|
|
{
|
|
|
|
/* Give an error if it's not given already */
|
2015-07-06 19:24:14 +02:00
|
|
|
my_message(ER_SET_CONSTANTS_ONLY, ER_THD(thd, ER_SET_CONSTANTS_ONLY),
|
|
|
|
MYF(0));
|
2002-09-22 17:02:39 +02:00
|
|
|
return -1;
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
2016-04-15 20:40:25 +02:00
|
|
|
|
2016-05-30 21:22:50 +02:00
|
|
|
SESSION_TRACKER_CHANGED(thd, SESSION_STATE_CHANGE_TRACKER, NULL);
|
2002-07-23 17:31:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET PASSWORD
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_password::check(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-09-26 12:33:13 +02:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2014-11-25 10:07:59 +01:00
|
|
|
return check_change_password(thd, user);
|
2004-07-30 22:05:08 +02:00
|
|
|
#else
|
2003-09-26 12:33:13 +02:00
|
|
|
return 0;
|
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2002-09-22 17:02:39 +02:00
|
|
|
int set_var_password::update(THD *thd)
|
2002-07-23 17:31:22 +02:00
|
|
|
{
|
2003-09-26 12:33:13 +02:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2015-02-27 20:13:51 +01:00
|
|
|
Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
|
|
|
|
thd->m_reprepare_observer= 0;
|
|
|
|
int res= change_password(thd, user);
|
|
|
|
thd->m_reprepare_observer= save_reprepare_observer;
|
|
|
|
return res;
|
2003-09-26 12:33:13 +02:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2002-07-23 17:31:22 +02:00
|
|
|
}
|
|
|
|
|
2013-10-18 00:11:21 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET ROLE
|
|
|
|
*****************************************************************************/
|
2014-07-14 01:57:10 +02:00
|
|
|
|
2013-10-18 00:11:21 +02:00
|
|
|
int set_var_role::check(THD *thd)
|
|
|
|
{
|
2013-10-18 05:39:23 +02:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2014-01-28 21:02:17 +01:00
|
|
|
int status= acl_check_setrole(thd, role.str, &access);
|
2013-10-18 05:39:23 +02:00
|
|
|
return status;
|
|
|
|
#else
|
2013-10-18 00:11:21 +02:00
|
|
|
return 0;
|
2013-10-18 05:39:23 +02:00
|
|
|
#endif
|
2013-10-18 00:11:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int set_var_role::update(THD *thd)
|
|
|
|
{
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2016-04-15 20:40:25 +02:00
|
|
|
int res= acl_setrole(thd, role.str, access);
|
|
|
|
if (!res)
|
|
|
|
thd->session_tracker.mark_as_changed(thd, SESSION_STATE_CHANGE_TRACKER,
|
|
|
|
NULL);
|
|
|
|
return res;
|
2013-10-18 00:11:21 +02:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-14 01:57:10 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET DEFAULT ROLE
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
int set_var_default_role::check(THD *thd)
|
|
|
|
{
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2015-02-27 20:13:51 +01:00
|
|
|
real_user= get_current_user(thd, user);
|
|
|
|
int status= acl_check_set_default_role(thd, real_user->host.str, real_user->user.str);
|
2014-07-14 01:57:10 +02:00
|
|
|
return status;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int set_var_default_role::update(THD *thd)
|
|
|
|
{
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2015-02-27 20:13:51 +01:00
|
|
|
Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
|
|
|
|
thd->m_reprepare_observer= 0;
|
|
|
|
int res= acl_set_default_role(thd, real_user->host.str, real_user->user.str, role.str);
|
|
|
|
thd->m_reprepare_observer= save_reprepare_observer;
|
|
|
|
return res;
|
2014-07-14 01:57:10 +02:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2013-10-18 00:11:21 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
Functions to handle SET NAMES and SET CHARACTER SET
|
|
|
|
*****************************************************************************/
|
2003-08-02 11:43:18 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
int set_var_collation_client::check(THD *thd)
|
2003-11-18 12:47:27 +01:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
/* Currently, UCS-2 cannot be used as a client character set */
|
2011-02-18 10:46:55 +01:00
|
|
|
if (!is_supported_parser_charset(character_set_client))
|
2003-08-02 11:43:18 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
|
|
|
|
character_set_client->csname);
|
|
|
|
return 1;
|
2003-08-02 11:43:18 +02:00
|
|
|
}
|
|
|
|
return 0;
|
2003-07-06 18:09:57 +02:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
int set_var_collation_client::update(THD *thd)
|
dbug changes:
1. dbug state is now local to a thread
2. new macros: DBUG_EXPLAIN, DBUG_EXPLAIN_INITIAL,
DBUG_SET, DBUG_SET_INITIAL, DBUG_EVALUATE, DBUG_EVALUATE_IF
3. macros are do{}while(0) wrapped
4. incremental modifications to the dbug state (e.g. "+d,info:-t")
5. dbug code cleanup, style fixes
6. _db_on_ and DEBUGGER_ON/OFF removed
7. rest of MySQL code fixed because of 3 (missing ;) and 6
8. dbug manual updated
9. server variable @@debug (global and local) to control dbug from SQL!
a. -#T to print timestamps in the log
BitKeeper/deleted/.del-readme.prof~2f3bae1550a0038d:
Delete: dbug/readme.prof
client/mysqlslap.c:
typo fixed
configure.in:
test for sleep() too
dbug/dbug.c:
thread local dbug settings
DBUG_EXPLAIN,DBUG_EXPLAIN_INITIAL,DBUG_SET,DBUG_SET_INITIAL
style changes to be more in line with MySQL code
cleanup (many mallocs removed)
incremental modification of dbug state (e.g. DBUG_PUSH("+t:-d,info"))
DBUG_SET, _db_explain_
-#T
dbug/monty.doc:
obsolete and duplicate docs removed
dbug/user.r:
new features documented
include/my_dbug.h:
correct do{}while wrapping
thread local dbug settings
DBUG_EXPLAIN,DBUG_EXPLAIN_INITIAL,DBUG_SET,DBUG_SET_INITIAL
DBUG_EVALUATE,DBUG_EVALUATE_IF
libmysql/libmysql.c:
remove _db_on_ and DEBUGGER_ON/OFF
mysys/my_init.c:
missed DBUG_RETURN
mysys/my_thr_init.c:
bugfix - transaction id's are unsigned
mysys/testhash.c:
remove _db_on_ and DEBUGGER_ON/OFF
sql/ha_myisammrg.cc:
missed ;
sql/ha_ndbcluster.cc:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
sql/ha_ndbcluster_binlog.cc:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
sql/item_cmpfunc.cc:
missed ;
sql/lock.cc:
missed DBUG_RETURN
sql/log_event.cc:
missed ;
sql/mysqld.cc:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
DBUG_SET_INITIAL
sql/opt_range.cc:
remove _db_on_ and DEBUGGER_ON/OFF
sql/set_var.cc:
class sys_var_thd_dbug and "debug" server variable
sql/set_var.h:
class sys_var_thd_dbug and "debug" server variable
sql/slave.cc:
missed ;
sql/sql_cache.cc:
missed ;
sql/sql_plugin.cc:
missed ;
sql/sql_select.cc:
remove _db_on_ and DEBUGGER_ON/OFF
storage/heap/hp_test2.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/ft_eval.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/ft_test1.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_open.c:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
storage/myisam/mi_test1.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_test2.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_test3.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/ndb/src/ndbapi/DictCache.cpp:
missed ;
storage/ndb/src/ndbapi/NdbTransaction.cpp:
missed ;
tests/mysql_client_test.c:
remove _db_on_ and DEBUGGER_ON/OFF
2006-02-14 22:36:11 +01:00
|
|
|
{
|
2016-06-24 23:57:27 +02:00
|
|
|
thd->update_charset(character_set_client, collation_connection,
|
|
|
|
character_set_results);
|
2016-04-15 20:40:25 +02:00
|
|
|
|
2016-04-15 20:47:45 +02:00
|
|
|
/* Mark client collation variables as changed */
|
2016-05-30 21:22:50 +02:00
|
|
|
#ifndef EMBEDDED_LIBRARY
|
2016-04-15 20:47:45 +02:00
|
|
|
if (thd->session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->is_enabled())
|
|
|
|
{
|
|
|
|
sys_var *svar;
|
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
if ((svar= find_sys_var_ex(thd, "character_set_client",
|
|
|
|
sizeof("character_set_client") - 1,
|
|
|
|
false, true)))
|
|
|
|
thd->session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->
|
|
|
|
mark_as_changed(thd, (LEX_CSTRING*)svar);
|
|
|
|
if ((svar= find_sys_var_ex(thd, "character_set_results",
|
|
|
|
sizeof("character_set_results") - 1,
|
|
|
|
false, true)))
|
|
|
|
thd->session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->
|
|
|
|
mark_as_changed(thd, (LEX_CSTRING*)svar);
|
|
|
|
if ((svar= find_sys_var_ex(thd, "character_set_connection",
|
|
|
|
sizeof("character_set_connection") - 1,
|
|
|
|
false, true)))
|
|
|
|
thd->session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->
|
|
|
|
mark_as_changed(thd, (LEX_CSTRING*)svar);
|
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
|
|
|
}
|
2016-04-15 20:40:25 +02:00
|
|
|
thd->session_tracker.mark_as_changed(thd, SESSION_STATE_CHANGE_TRACKER, NULL);
|
2016-05-30 21:22:50 +02:00
|
|
|
#endif //EMBEDDED_LIBRARY
|
2016-04-15 20:47:45 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
thd->protocol_text.init(thd);
|
|
|
|
thd->protocol_binary.init(thd);
|
dbug changes:
1. dbug state is now local to a thread
2. new macros: DBUG_EXPLAIN, DBUG_EXPLAIN_INITIAL,
DBUG_SET, DBUG_SET_INITIAL, DBUG_EVALUATE, DBUG_EVALUATE_IF
3. macros are do{}while(0) wrapped
4. incremental modifications to the dbug state (e.g. "+d,info:-t")
5. dbug code cleanup, style fixes
6. _db_on_ and DEBUGGER_ON/OFF removed
7. rest of MySQL code fixed because of 3 (missing ;) and 6
8. dbug manual updated
9. server variable @@debug (global and local) to control dbug from SQL!
a. -#T to print timestamps in the log
BitKeeper/deleted/.del-readme.prof~2f3bae1550a0038d:
Delete: dbug/readme.prof
client/mysqlslap.c:
typo fixed
configure.in:
test for sleep() too
dbug/dbug.c:
thread local dbug settings
DBUG_EXPLAIN,DBUG_EXPLAIN_INITIAL,DBUG_SET,DBUG_SET_INITIAL
style changes to be more in line with MySQL code
cleanup (many mallocs removed)
incremental modification of dbug state (e.g. DBUG_PUSH("+t:-d,info"))
DBUG_SET, _db_explain_
-#T
dbug/monty.doc:
obsolete and duplicate docs removed
dbug/user.r:
new features documented
include/my_dbug.h:
correct do{}while wrapping
thread local dbug settings
DBUG_EXPLAIN,DBUG_EXPLAIN_INITIAL,DBUG_SET,DBUG_SET_INITIAL
DBUG_EVALUATE,DBUG_EVALUATE_IF
libmysql/libmysql.c:
remove _db_on_ and DEBUGGER_ON/OFF
mysys/my_init.c:
missed DBUG_RETURN
mysys/my_thr_init.c:
bugfix - transaction id's are unsigned
mysys/testhash.c:
remove _db_on_ and DEBUGGER_ON/OFF
sql/ha_myisammrg.cc:
missed ;
sql/ha_ndbcluster.cc:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
sql/ha_ndbcluster_binlog.cc:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
sql/item_cmpfunc.cc:
missed ;
sql/lock.cc:
missed DBUG_RETURN
sql/log_event.cc:
missed ;
sql/mysqld.cc:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
DBUG_SET_INITIAL
sql/opt_range.cc:
remove _db_on_ and DEBUGGER_ON/OFF
sql/set_var.cc:
class sys_var_thd_dbug and "debug" server variable
sql/set_var.h:
class sys_var_thd_dbug and "debug" server variable
sql/slave.cc:
missed ;
sql/sql_cache.cc:
missed ;
sql/sql_plugin.cc:
missed ;
sql/sql_select.cc:
remove _db_on_ and DEBUGGER_ON/OFF
storage/heap/hp_test2.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/ft_eval.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/ft_test1.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_open.c:
remove _db_on_ and DEBUGGER_ON/OFF
missed ;
storage/myisam/mi_test1.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_test2.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_test3.c:
remove _db_on_ and DEBUGGER_ON/OFF
storage/ndb/src/ndbapi/DictCache.cpp:
missed ;
storage/ndb/src/ndbapi/NdbTransaction.cpp:
missed ;
tests/mysql_client_test.c:
remove _db_on_ and DEBUGGER_ON/OFF
2006-02-14 22:36:11 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-03 20:16:51 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
INFORMATION_SCHEMA.SYSTEM_VARIABLES
|
|
|
|
*****************************************************************************/
|
|
|
|
static void store_value_ptr(Field *field, sys_var *var, String *str,
|
|
|
|
uchar *value_ptr)
|
|
|
|
{
|
|
|
|
field->set_notnull();
|
|
|
|
str= var->val_str_nolock(str, field->table->in_use, value_ptr);
|
|
|
|
if (str)
|
|
|
|
field->store(str->ptr(), str->length(), str->charset());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void store_var(Field *field, sys_var *var, enum_var_type scope,
|
|
|
|
String *str)
|
|
|
|
{
|
|
|
|
if (var->check_type(scope))
|
|
|
|
return;
|
|
|
|
|
|
|
|
store_value_ptr(field, var, str,
|
2017-04-23 18:39:57 +02:00
|
|
|
var->value_ptr(field->table->in_use, scope, &null_clex_str));
|
2014-09-03 20:16:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond)
|
|
|
|
{
|
|
|
|
char name_buffer[NAME_CHAR_LEN];
|
|
|
|
enum_check_fields save_count_cuted_fields= thd->count_cuted_fields;
|
|
|
|
bool res= 1;
|
|
|
|
CHARSET_INFO *scs= system_charset_info;
|
|
|
|
StringBuffer<STRING_BUFFER_USUAL_SIZE> strbuf(scs);
|
|
|
|
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : 0;
|
|
|
|
Field **fields=tables->table->field;
|
|
|
|
|
|
|
|
DBUG_ASSERT(tables->table->in_use == thd);
|
|
|
|
|
2015-08-11 09:18:38 +02:00
|
|
|
cond= make_cond_for_info_schema(thd, cond, tables);
|
2014-09-03 20:16:51 +02:00
|
|
|
thd->count_cuted_fields= CHECK_FIELD_WARN;
|
|
|
|
mysql_rwlock_rdlock(&LOCK_system_variables_hash);
|
|
|
|
|
|
|
|
for (uint i= 0; i < system_variable_hash.records; i++)
|
|
|
|
{
|
|
|
|
sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i);
|
|
|
|
|
|
|
|
strmake_buf(name_buffer, var->name.str);
|
|
|
|
my_caseup_str(system_charset_info, name_buffer);
|
|
|
|
|
|
|
|
/* this must be done before evaluating cond */
|
|
|
|
restore_record(tables->table, s->default_values);
|
|
|
|
fields[0]->store(name_buffer, strlen(name_buffer), scs);
|
|
|
|
|
|
|
|
if ((wild && wild_case_compare(system_charset_info, name_buffer, wild))
|
|
|
|
|| (cond && !cond->val_int()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mysql_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
|
|
|
|
// SESSION_VALUE
|
|
|
|
store_var(fields[1], var, OPT_SESSION, &strbuf);
|
|
|
|
|
|
|
|
// GLOBAL_VALUE
|
|
|
|
store_var(fields[2], var, OPT_GLOBAL, &strbuf);
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// GLOBAL_VALUE_ORIGIN
|
|
|
|
static const LEX_CSTRING origins[]=
|
|
|
|
{
|
|
|
|
{ STRING_WITH_LEN("CONFIG") },
|
|
|
|
{ STRING_WITH_LEN("AUTO") },
|
|
|
|
{ STRING_WITH_LEN("SQL") },
|
2014-09-03 15:16:43 +02:00
|
|
|
{ STRING_WITH_LEN("COMPILE-TIME") },
|
|
|
|
{ STRING_WITH_LEN("ENVIRONMENT") }
|
2014-09-01 20:29:58 +02:00
|
|
|
};
|
|
|
|
const LEX_CSTRING *origin= origins + var->value_origin;
|
|
|
|
fields[3]->store(origin->str, origin->length, scs);
|
|
|
|
|
2014-09-03 20:16:51 +02:00
|
|
|
// DEFAULT_VALUE
|
|
|
|
uchar *def= var->is_readonly() && var->option.id < 0
|
|
|
|
? 0 : var->default_value_ptr(thd);
|
|
|
|
if (def)
|
2014-09-01 20:29:58 +02:00
|
|
|
store_value_ptr(fields[4], var, &strbuf, def);
|
2014-09-03 20:16:51 +02:00
|
|
|
|
|
|
|
mysql_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// VARIABLE_SCOPE
|
2014-09-03 20:16:51 +02:00
|
|
|
static const LEX_CSTRING scopes[]=
|
|
|
|
{
|
|
|
|
{ STRING_WITH_LEN("GLOBAL") },
|
|
|
|
{ STRING_WITH_LEN("SESSION") },
|
|
|
|
{ STRING_WITH_LEN("SESSION ONLY") }
|
|
|
|
};
|
|
|
|
const LEX_CSTRING *scope= scopes + var->scope();
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[5]->store(scope->str, scope->length, scs);
|
2014-09-03 20:16:51 +02:00
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// VARIABLE_TYPE
|
2014-09-03 20:16:51 +02:00
|
|
|
#if SIZEOF_LONG == SIZEOF_INT
|
|
|
|
#define LONG_TYPE "INT"
|
|
|
|
#else
|
|
|
|
#define LONG_TYPE "BIGINT"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const LEX_CSTRING types[]=
|
|
|
|
{
|
|
|
|
{ 0, 0 }, // unused 0
|
|
|
|
{ 0, 0 }, // GET_NO_ARG 1
|
|
|
|
{ STRING_WITH_LEN("BOOLEAN") }, // GET_BOOL 2
|
|
|
|
{ STRING_WITH_LEN("INT") }, // GET_INT 3
|
|
|
|
{ STRING_WITH_LEN("INT UNSIGNED") }, // GET_UINT 4
|
|
|
|
{ STRING_WITH_LEN(LONG_TYPE) }, // GET_LONG 5
|
|
|
|
{ STRING_WITH_LEN(LONG_TYPE " UNSIGNED") }, // GET_ULONG 6
|
|
|
|
{ STRING_WITH_LEN("BIGINT") }, // GET_LL 7
|
|
|
|
{ STRING_WITH_LEN("BIGINT UNSIGNED") }, // GET_ULL 8
|
|
|
|
{ STRING_WITH_LEN("VARCHAR") }, // GET_STR 9
|
|
|
|
{ STRING_WITH_LEN("VARCHAR") }, // GET_STR_ALLOC 10
|
|
|
|
{ 0, 0 }, // GET_DISABLED 11
|
|
|
|
{ STRING_WITH_LEN("ENUM") }, // GET_ENUM 12
|
|
|
|
{ STRING_WITH_LEN("SET") }, // GET_SET 13
|
|
|
|
{ STRING_WITH_LEN("DOUBLE") }, // GET_DOUBLE 14
|
|
|
|
{ STRING_WITH_LEN("FLAGSET") }, // GET_FLAGSET 15
|
|
|
|
};
|
2015-08-10 21:45:11 +02:00
|
|
|
const ulong vartype= (var->option.var_type & GET_TYPE_MASK);
|
|
|
|
const LEX_CSTRING *type= types + vartype;
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[6]->store(type->str, type->length, scs);
|
2014-09-03 20:16:51 +02:00
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// VARIABLE_COMMENT
|
|
|
|
fields[7]->store(var->option.comment, strlen(var->option.comment),
|
2014-09-03 20:16:51 +02:00
|
|
|
scs);
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// NUMERIC_MIN_VALUE
|
|
|
|
// NUMERIC_MAX_VALUE
|
|
|
|
// NUMERIC_BLOCK_SIZE
|
2014-09-03 20:16:51 +02:00
|
|
|
bool is_unsigned= true;
|
2015-08-10 21:45:11 +02:00
|
|
|
switch (vartype)
|
2014-09-03 20:16:51 +02:00
|
|
|
{
|
|
|
|
case GET_INT:
|
|
|
|
case GET_LONG:
|
|
|
|
case GET_LL:
|
|
|
|
is_unsigned= false;
|
|
|
|
/* fall through */
|
|
|
|
case GET_UINT:
|
|
|
|
case GET_ULONG:
|
|
|
|
case GET_ULL:
|
|
|
|
fields[8]->set_notnull();
|
|
|
|
fields[9]->set_notnull();
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[10]->set_notnull();
|
|
|
|
fields[8]->store(var->option.min_value, is_unsigned);
|
|
|
|
fields[9]->store(var->option.max_value, is_unsigned);
|
|
|
|
fields[10]->store(var->option.block_size, is_unsigned);
|
2014-09-03 20:16:51 +02:00
|
|
|
break;
|
|
|
|
case GET_DOUBLE:
|
|
|
|
fields[8]->set_notnull();
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[9]->set_notnull();
|
|
|
|
fields[8]->store(getopt_ulonglong2double(var->option.min_value));
|
|
|
|
fields[9]->store(getopt_ulonglong2double(var->option.max_value));
|
2014-09-03 20:16:51 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// ENUM_VALUE_LIST
|
2014-09-03 20:16:51 +02:00
|
|
|
TYPELIB *tl= var->option.typelib;
|
|
|
|
if (tl)
|
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
strbuf.length(0);
|
|
|
|
for (i=0; i + 1 < tl->count; i++)
|
|
|
|
{
|
|
|
|
strbuf.append(tl->type_names[i]);
|
|
|
|
strbuf.append(',');
|
|
|
|
}
|
|
|
|
strbuf.append(tl->type_names[i]);
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[11]->set_notnull();
|
|
|
|
fields[11]->store(strbuf.ptr(), strbuf.length(), scs);
|
2014-09-03 20:16:51 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// READ_ONLY
|
2014-09-03 20:16:51 +02:00
|
|
|
static const LEX_CSTRING yesno[]=
|
|
|
|
{
|
|
|
|
{ STRING_WITH_LEN("NO") },
|
|
|
|
{ STRING_WITH_LEN("YES") }
|
|
|
|
};
|
|
|
|
const LEX_CSTRING *yn = yesno + var->is_readonly();
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[12]->store(yn->str, yn->length, scs);
|
2014-09-03 20:16:51 +02:00
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
// COMMAND_LINE_ARGUMENT
|
2014-09-03 20:16:51 +02:00
|
|
|
if (var->option.id >= 0)
|
|
|
|
{
|
|
|
|
static const LEX_CSTRING args[]=
|
|
|
|
{
|
|
|
|
{ STRING_WITH_LEN("NONE") }, // NO_ARG
|
|
|
|
{ STRING_WITH_LEN("OPTIONAL") }, // OPT_ARG
|
|
|
|
{ STRING_WITH_LEN("REQUIRED") } // REQUIRED_ARG
|
|
|
|
};
|
|
|
|
const LEX_CSTRING *arg= args + var->option.arg_type;
|
2014-09-01 20:29:58 +02:00
|
|
|
fields[13]->set_notnull();
|
|
|
|
fields[13]->store(arg->str, arg->length, scs);
|
2014-09-03 20:16:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (schema_table_store_record(thd, tables->table))
|
|
|
|
goto end;
|
|
|
|
thd->get_stmt_da()->inc_current_row_for_warning();
|
|
|
|
}
|
|
|
|
res= 0;
|
|
|
|
end:
|
|
|
|
mysql_rwlock_unlock(&LOCK_system_variables_hash);
|
|
|
|
thd->count_cuted_fields= save_count_cuted_fields;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-09-03 15:16:43 +02:00
|
|
|
/*
|
|
|
|
This is a simple and inefficient helper that sets sys_var::value_origin
|
|
|
|
for a specific sysvar.
|
|
|
|
It should *only* be used on server startup, if you need to do this later,
|
|
|
|
get yourself a pointer to your sysvar (see e.g. Sys_autocommit_ptr)
|
|
|
|
and update it directly.
|
|
|
|
*/
|
|
|
|
|
2015-08-10 21:45:11 +02:00
|
|
|
void set_sys_var_value_origin(void *ptr, enum sys_var::where here)
|
2014-09-03 15:16:43 +02:00
|
|
|
{
|
2014-12-22 01:02:38 +01:00
|
|
|
bool found __attribute__((unused))= false;
|
2014-09-03 15:16:43 +02:00
|
|
|
DBUG_ASSERT(!mysqld_server_started); // only to be used during startup
|
|
|
|
|
|
|
|
for (uint i= 0; i < system_variable_hash.records; i++)
|
|
|
|
{
|
|
|
|
sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i);
|
|
|
|
if (var->option.value == ptr)
|
|
|
|
{
|
|
|
|
found= true;
|
|
|
|
var->value_origin= here;
|
|
|
|
/* don't break early, search for all matches */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBUG_ASSERT(found); // variable must have been found
|
|
|
|
}
|
|
|
|
|
2015-08-10 21:45:11 +02:00
|
|
|
enum sys_var::where get_sys_var_value_origin(void *ptr)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(!mysqld_server_started); // only to be used during startup
|
|
|
|
|
|
|
|
for (uint i= 0; i < system_variable_hash.records; i++)
|
|
|
|
{
|
|
|
|
sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i);
|
|
|
|
if (var->option.value == ptr)
|
|
|
|
{
|
|
|
|
return var->value_origin; //first match
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBUG_ASSERT(0); // variable must have been found
|
|
|
|
return sys_var::CONFIG;
|
|
|
|
}
|
|
|
|
|
2017-03-20 11:55:24 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Find the next item in string of comma-separated items.
|
|
|
|
END_POS points at the end of the string.
|
|
|
|
ITEM_START and ITEM_END return the limits of the next item.
|
|
|
|
Returns true while items are available, false at the end.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
engine_list_next_item(const char **pos, const char *end_pos,
|
|
|
|
const char **item_start, const char **item_end)
|
|
|
|
{
|
|
|
|
if (*pos >= end_pos)
|
|
|
|
return false;
|
|
|
|
*item_start= *pos;
|
|
|
|
while (*pos < end_pos && **pos != ',')
|
|
|
|
++*pos;
|
|
|
|
*item_end= *pos;
|
|
|
|
++*pos;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
2017-04-20 16:19:01 +02:00
|
|
|
resolve_engine_list_item(THD *thd, plugin_ref *list, uint32 *idx,
|
2017-03-24 12:06:29 +01:00
|
|
|
const char *pos, const char *pos_end,
|
2017-04-20 16:19:01 +02:00
|
|
|
bool error_on_unknown_engine, bool temp_copy)
|
2017-03-20 11:55:24 +01:00
|
|
|
{
|
2017-07-03 10:36:09 +02:00
|
|
|
LEX_CSTRING item_str;
|
2017-03-20 11:55:24 +01:00
|
|
|
plugin_ref ref;
|
|
|
|
uint32_t i;
|
2017-04-20 16:19:01 +02:00
|
|
|
THD *thd_or_null = (temp_copy ? thd : NULL);
|
2017-03-20 11:55:24 +01:00
|
|
|
|
2017-07-03 10:36:09 +02:00
|
|
|
item_str.str= pos;
|
2017-03-20 11:55:24 +01:00
|
|
|
item_str.length= pos_end-pos;
|
2017-04-20 16:19:01 +02:00
|
|
|
ref= ha_resolve_by_name(thd_or_null, &item_str, false);
|
2017-03-20 11:55:24 +01:00
|
|
|
if (!ref)
|
|
|
|
{
|
2017-03-24 12:06:29 +01:00
|
|
|
if (error_on_unknown_engine)
|
|
|
|
{
|
|
|
|
ErrConvString err(pos, pos_end-pos, system_charset_info);
|
|
|
|
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), err.ptr());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-03-20 11:55:24 +01:00
|
|
|
}
|
|
|
|
/* Ignore duplicates, like --plugin-load does. */
|
|
|
|
for (i= 0; i < *idx; ++i)
|
|
|
|
{
|
|
|
|
if (plugin_hton(list[i]) == plugin_hton(ref))
|
|
|
|
{
|
2017-04-20 16:19:01 +02:00
|
|
|
if (!temp_copy)
|
|
|
|
plugin_unlock(NULL, ref);
|
2017-03-20 11:55:24 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list[*idx]= ref;
|
|
|
|
++*idx;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Helper for class Sys_var_pluginlist.
|
|
|
|
Resolve a comma-separated list of storage engine names to a null-terminated
|
|
|
|
array of plugin_ref.
|
2017-04-20 16:19:01 +02:00
|
|
|
|
|
|
|
If TEMP_COPY is true, a THD must be given as well. In this case, the
|
|
|
|
allocated memory and locked plugins are registered in the THD and will
|
|
|
|
be freed / unlocked automatically. If TEMP_COPY is true, THD can be
|
|
|
|
passed as NULL, and resources must be freed explicitly later with
|
|
|
|
free_engine_list().
|
2017-03-20 11:55:24 +01:00
|
|
|
*/
|
|
|
|
plugin_ref *
|
2017-04-20 16:19:01 +02:00
|
|
|
resolve_engine_list(THD *thd, const char *str_arg, size_t str_arg_len,
|
|
|
|
bool error_on_unknown_engine, bool temp_copy)
|
2017-03-20 11:55:24 +01:00
|
|
|
{
|
|
|
|
uint32 count, idx;
|
|
|
|
const char *pos, *item_start, *item_end;
|
|
|
|
const char *str_arg_end= str_arg + str_arg_len;
|
|
|
|
plugin_ref *res;
|
|
|
|
|
|
|
|
count= 0;
|
|
|
|
pos= str_arg;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!engine_list_next_item(&pos, str_arg_end, &item_start, &item_end))
|
|
|
|
break;
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
2017-04-20 16:19:01 +02:00
|
|
|
if (temp_copy)
|
|
|
|
res= (plugin_ref *)thd->calloc((count+1)*sizeof(*res));
|
|
|
|
else
|
|
|
|
res= (plugin_ref *)my_malloc((count+1)*sizeof(*res), MYF(MY_ZEROFILL|MY_WME));
|
2017-03-20 11:55:24 +01:00
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
my_error(ER_OUTOFMEMORY, MYF(0), (int)((count+1)*sizeof(*res)));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
idx= 0;
|
|
|
|
pos= str_arg;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!engine_list_next_item(&pos, str_arg_end, &item_start, &item_end))
|
|
|
|
break;
|
|
|
|
DBUG_ASSERT(idx < count);
|
|
|
|
if (idx >= count)
|
|
|
|
break;
|
2017-04-20 16:19:01 +02:00
|
|
|
if (resolve_engine_list_item(thd, res, &idx, item_start, item_end,
|
|
|
|
error_on_unknown_engine, temp_copy))
|
2017-03-20 11:55:24 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
err:
|
2017-04-20 16:19:01 +02:00
|
|
|
if (!temp_copy)
|
|
|
|
free_engine_list(res);
|
2017-03-20 11:55:24 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
free_engine_list(plugin_ref *list)
|
|
|
|
{
|
|
|
|
plugin_ref *p;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
for (p= list; *p; ++p)
|
|
|
|
plugin_unlock(NULL, *p);
|
|
|
|
my_free(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
plugin_ref *
|
|
|
|
copy_engine_list(plugin_ref *list)
|
|
|
|
{
|
|
|
|
plugin_ref *p;
|
|
|
|
uint32 count, i;
|
|
|
|
|
|
|
|
for (p= list, count= 0; *p; ++p, ++count)
|
|
|
|
;
|
|
|
|
p= (plugin_ref *)my_malloc((count+1)*sizeof(*p), MYF(0));
|
|
|
|
if (!p)
|
|
|
|
{
|
|
|
|
my_error(ER_OUTOFMEMORY, MYF(0), (int)((count+1)*sizeof(*p)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
for (i= 0; i < count; ++i)
|
|
|
|
p[i]= my_plugin_lock(NULL, list[i]);
|
2017-04-20 16:19:01 +02:00
|
|
|
p[i] = NULL;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Create a temporary copy of an engine list. The memory will be freed
|
|
|
|
(and the plugins unlocked) automatically, on the passed THD.
|
|
|
|
*/
|
|
|
|
plugin_ref *
|
|
|
|
temp_copy_engine_list(THD *thd, plugin_ref *list)
|
|
|
|
{
|
|
|
|
plugin_ref *p;
|
|
|
|
uint32 count, i;
|
|
|
|
|
|
|
|
for (p= list, count= 0; *p; ++p, ++count)
|
|
|
|
;
|
|
|
|
p= (plugin_ref *)thd->alloc((count+1)*sizeof(*p));
|
|
|
|
if (!p)
|
|
|
|
{
|
|
|
|
my_error(ER_OUTOFMEMORY, MYF(0), (int)((count+1)*sizeof(*p)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
for (i= 0; i < count; ++i)
|
|
|
|
p[i]= my_plugin_lock(thd, list[i]);
|
|
|
|
p[i] = NULL;
|
2017-03-20 11:55:24 +01:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
pretty_print_engine_list(THD *thd, plugin_ref *list)
|
|
|
|
{
|
|
|
|
plugin_ref *p;
|
|
|
|
size_t size;
|
|
|
|
char *buf, *pos;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return thd->strmake("", 0);
|
|
|
|
|
|
|
|
size= 0;
|
|
|
|
for (p= list; *p; ++p)
|
|
|
|
size+= plugin_name(*p)->length + 1;
|
|
|
|
buf= static_cast<char *>(thd->alloc(size));
|
|
|
|
if (!buf)
|
|
|
|
return NULL;
|
|
|
|
pos= buf;
|
|
|
|
for (p= list; *p; ++p)
|
|
|
|
{
|
2017-07-03 10:36:09 +02:00
|
|
|
LEX_CSTRING *name;
|
2017-03-20 11:55:24 +01:00
|
|
|
size_t remain;
|
|
|
|
|
|
|
|
remain= buf + size - pos;
|
|
|
|
DBUG_ASSERT(remain > 0);
|
|
|
|
if (remain <= 1)
|
|
|
|
break;
|
|
|
|
if (pos != buf)
|
|
|
|
{
|
|
|
|
pos= strmake(pos, ",", remain-1);
|
|
|
|
--remain;
|
|
|
|
}
|
|
|
|
name= plugin_name(*p);
|
|
|
|
pos= strmake(pos, name->str, MY_MIN(name->length, remain-1));
|
|
|
|
}
|
|
|
|
*pos= '\0';
|
|
|
|
return buf;
|
|
|
|
}
|