2009-09-23 23:32:31 +02:00
|
|
|
#ifndef SET_VAR_INCLUDED
|
|
|
|
#define SET_VAR_INCLUDED
|
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) 2009, 2014, SkySQL Ab.
|
2009-09-23 23:32:31 +02:00
|
|
|
|
2009-12-22 10:35:56 +01: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
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
2005-11-06 01:36:40 +01:00
|
|
|
|
2009-12-22 10:35:56 +01: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.
|
2008-11-28 15:25:16 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
2008-11-28 15:25:16 +01:00
|
|
|
|
2008-11-22 00:22:21 +01:00
|
|
|
/**
|
2009-12-22 10:35:56 +01:00
|
|
|
@file
|
|
|
|
"public" interface to sys_var - server configuration variables.
|
2008-11-22 00:22:21 +01:00
|
|
|
*/
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
#ifdef USE_PRAGMA_INTERFACE
|
|
|
|
#pragma interface /* gcc class implementation */
|
|
|
|
#endif
|
2004-12-29 18:30:37 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
#include <my_getopt.h>
|
2007-07-30 10:33:50 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
class sys_var;
|
|
|
|
class set_var;
|
|
|
|
class sys_var_pluginvar;
|
|
|
|
class PolyLock;
|
2010-03-31 16:05:33 +02:00
|
|
|
class Item_func_set_user_var;
|
|
|
|
|
|
|
|
// This include needs to be here since item.h requires enum_var_type :-P
|
|
|
|
#include "item.h" /* Item */
|
2011-12-02 14:16:48 +01:00
|
|
|
#include "sql_class.h" /* THD */
|
2008-11-20 08:51:48 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
extern TYPELIB bool_typelib;
|
2008-11-20 08:51:48 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
struct sys_var_chain
|
2007-07-30 10:33:50 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
sys_var *first;
|
|
|
|
sys_var *last;
|
2007-07-30 10:33:50 +02:00
|
|
|
};
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
int mysql_add_sys_var_chain(sys_var *chain);
|
|
|
|
int mysql_del_sys_var_chain(sys_var *chain);
|
2007-07-30 10:33:50 +02:00
|
|
|
|
2016-04-15 20:47:45 +02:00
|
|
|
|
2006-11-21 04:40:35 +01:00
|
|
|
/**
|
2009-12-22 10:35:56 +01:00
|
|
|
A class representing one system variable - that is something
|
|
|
|
that can be accessed as @@global.variable_name or @@session.variable_name,
|
|
|
|
visible in SHOW xxx VARIABLES and in INFORMATION_SCHEMA.xxx_VARIABLES,
|
|
|
|
optionally it can be assigned to, optionally it can have a command-line
|
|
|
|
counterpart with the same name.
|
2006-11-21 04:40:35 +01:00
|
|
|
*/
|
2015-09-17 09:05:07 +02:00
|
|
|
class sys_var: protected Value_source // for double_from_string_with_check
|
2006-11-21 04:40:35 +01:00
|
|
|
{
|
|
|
|
public:
|
2009-12-22 10:35:56 +01:00
|
|
|
sys_var *next;
|
|
|
|
LEX_CSTRING name;
|
2016-04-15 20:47:45 +02:00
|
|
|
bool *test_load;
|
2009-12-22 10:35:56 +01:00
|
|
|
enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023,
|
2014-10-24 10:13:08 +02:00
|
|
|
READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096,
|
2015-08-10 21:45:11 +02:00
|
|
|
NO_SET_STATEMENT=8192, AUTO_SET=16384};
|
2014-08-27 16:05:54 +02:00
|
|
|
enum { NO_GETOPT=-1, GETOPT_ONLY_HELP=-2 };
|
2019-09-29 22:07:48 +02:00
|
|
|
enum where { CONFIG, COMMAND_LINE, AUTO, SQL, COMPILE_TIME, ENV };
|
2014-08-27 16:05:54 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
Enumeration type to indicate for a system variable whether
|
|
|
|
it will be written to the binlog or not.
|
|
|
|
*/
|
|
|
|
enum binlog_status_enum { VARIABLE_NOT_IN_BINLOG,
|
|
|
|
SESSION_VARIABLE_IN_BINLOG } binlog_status;
|
2006-11-21 04:40:35 +01:00
|
|
|
|
2012-10-01 01:30:44 +02:00
|
|
|
my_option option; ///< min, max, default values are stored here
|
2014-09-01 20:29:58 +02:00
|
|
|
enum where value_origin;
|
2019-09-29 22:07:48 +02:00
|
|
|
const char *origin_filename;
|
2012-10-01 01:30:44 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
protected:
|
|
|
|
typedef bool (*on_check_function)(sys_var *self, THD *thd, set_var *var);
|
|
|
|
typedef bool (*on_update_function)(sys_var *self, THD *thd, enum_var_type type);
|
|
|
|
|
|
|
|
int flags; ///< or'ed flag_enum values
|
|
|
|
const SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc
|
|
|
|
PolyLock *guard; ///< *second* lock that protects the variable
|
|
|
|
ptrdiff_t offset; ///< offset to the value from global_system_variables
|
|
|
|
on_check_function on_check;
|
|
|
|
on_update_function on_update;
|
2012-08-24 10:17:08 +02:00
|
|
|
const char *const deprecation_substitute;
|
2009-12-22 10:35:56 +01:00
|
|
|
bool is_os_charset; ///< true if the value is in character_set_filesystem
|
|
|
|
|
|
|
|
public:
|
|
|
|
sys_var(sys_var_chain *chain, const char *name_arg, const char *comment,
|
|
|
|
int flag_args, 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);
|
2010-09-09 14:37:09 +02:00
|
|
|
|
|
|
|
virtual ~sys_var() {}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
2010-09-02 20:37:04 +02:00
|
|
|
All the cleanup procedures should be performed here
|
2009-12-22 10:35:56 +01:00
|
|
|
*/
|
2010-09-02 20:37:04 +02:00
|
|
|
virtual void cleanup() {}
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
downcast for sys_var_pluginvar. Returns this if it's an instance
|
|
|
|
of sys_var_pluginvar, and 0 otherwise.
|
|
|
|
*/
|
|
|
|
virtual sys_var_pluginvar *cast_pluginvar() { return 0; }
|
2009-10-15 14:23:43 +02:00
|
|
|
|
2006-07-04 14:40:40 +02:00
|
|
|
bool check(THD *thd, set_var *var);
|
2017-04-23 18:39:57 +02:00
|
|
|
uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base);
|
2013-02-25 05:58:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Update the system variable with the default value from either
|
|
|
|
session or global scope. The default value is stored in the
|
|
|
|
'var' argument. Return false when successful.
|
|
|
|
*/
|
|
|
|
bool set_default(THD *thd, set_var *var);
|
2009-10-15 14:23:43 +02:00
|
|
|
bool update(THD *thd, set_var *var);
|
|
|
|
|
2014-08-31 13:39:05 +02:00
|
|
|
String *val_str_nolock(String *str, THD *thd, const uchar *value);
|
2017-04-23 18:39:57 +02:00
|
|
|
longlong val_int(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base);
|
|
|
|
String *val_str(String *str, THD *thd, enum_var_type type, const LEX_CSTRING *base);
|
|
|
|
double val_real(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base);
|
2013-04-09 23:27:19 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
SHOW_TYPE show_type() { return show_val_type; }
|
|
|
|
int scope() const { return flags & SCOPE_MASK; }
|
|
|
|
CHARSET_INFO *charset(THD *thd);
|
|
|
|
bool is_readonly() const { return flags & READONLY; }
|
|
|
|
/**
|
|
|
|
the following is only true for keycache variables,
|
|
|
|
that support the syntax @@keycache_name.variable_name
|
|
|
|
*/
|
|
|
|
bool is_struct() { return option.var_type & GET_ASK_ADDR; }
|
2014-10-24 10:13:08 +02:00
|
|
|
bool is_set_stmt_ok() const { return !(flags & NO_SET_STATEMENT); }
|
2009-12-22 10:35:56 +01:00
|
|
|
bool is_written_to_binlog(enum_var_type type)
|
|
|
|
{ return type != OPT_GLOBAL && binlog_status == SESSION_VARIABLE_IN_BINLOG; }
|
2016-03-21 21:09:04 +01:00
|
|
|
bool check_update_type(const Item *item)
|
2014-08-27 20:32:32 +02:00
|
|
|
{
|
2016-03-21 21:09:04 +01:00
|
|
|
Item_result type= item->result_type();
|
2014-08-27 20:32:32 +02:00
|
|
|
switch (option.var_type & GET_TYPE_MASK) {
|
|
|
|
case GET_INT:
|
|
|
|
case GET_UINT:
|
|
|
|
case GET_LONG:
|
|
|
|
case GET_ULONG:
|
|
|
|
case GET_LL:
|
|
|
|
case GET_ULL:
|
2016-03-21 21:09:04 +01:00
|
|
|
return type != INT_RESULT &&
|
|
|
|
(type != DECIMAL_RESULT || item->decimals != 0);
|
2014-08-27 20:32:32 +02:00
|
|
|
case GET_STR:
|
|
|
|
case GET_STR_ALLOC:
|
|
|
|
return type != STRING_RESULT;
|
|
|
|
case GET_ENUM:
|
|
|
|
case GET_BOOL:
|
|
|
|
case GET_SET:
|
|
|
|
case GET_FLAGSET:
|
2017-07-21 18:56:41 +02:00
|
|
|
case GET_BIT:
|
2014-08-27 20:32:32 +02:00
|
|
|
return type != STRING_RESULT && type != INT_RESULT;
|
|
|
|
case GET_DOUBLE:
|
|
|
|
return type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
bool check_type(enum_var_type type)
|
WL#3337 (Event scheduler new architecture)
This is a post-review patch.
Fixes the typelib implementation, available only in 5.1.11.
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
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_restart_phase1.result:
update result
mysql-test/r/events_restart_phase3.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/events.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_bugs.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_logs_tests.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase1.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase2-master.opt:
update master file : 1 => on
mysql-test/t/events_scheduling.test:
update test:
2 -> off
1 -> on
add tests for event_scheduler global variable representation from
SHOW VARIABLES.
mysql-test/t/events_stress.test:
update test:
2 -> off
1 -> on
sql/events.cc:
Implement two different TYPELIBs for --event-scheduler cmd line
option and for GLOBAL variable event_scheduler
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
sql/events.h:
additional TYPELIB for GLOBAL event_scheduler
sql/mysqld.cc:
--event-scheduler should be checked against a TYPELIB and
therefore should be GET_STR, as well as we make the parameter optional.
When not provided OFF|0 is used.
sql/set_var.cc:
Implement typelib for event_scheduler variable.
If allows both INT_RESULT -> 0 | 1
and STRING_RESULT -> OFF | ON
The variable is shown as DISABLED | ON | OFF
sql/set_var.h:
Implement typelib, which expects both STRING and INT,
for event_scheduler.
2006-09-01 13:08:44 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
switch (scope())
|
|
|
|
{
|
|
|
|
case GLOBAL: return type != OPT_GLOBAL;
|
|
|
|
case SESSION: return false; // always ok
|
|
|
|
case ONLY_SESSION: return type == OPT_GLOBAL;
|
|
|
|
}
|
|
|
|
return true; // keep gcc happy
|
WL#3337 (Event scheduler new architecture)
This is a post-review patch.
Fixes the typelib implementation, available only in 5.1.11.
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
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_restart_phase1.result:
update result
mysql-test/r/events_restart_phase3.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/events.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_bugs.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_logs_tests.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase1.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase2-master.opt:
update master file : 1 => on
mysql-test/t/events_scheduling.test:
update test:
2 -> off
1 -> on
add tests for event_scheduler global variable representation from
SHOW VARIABLES.
mysql-test/t/events_stress.test:
update test:
2 -> off
1 -> on
sql/events.cc:
Implement two different TYPELIBs for --event-scheduler cmd line
option and for GLOBAL variable event_scheduler
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
sql/events.h:
additional TYPELIB for GLOBAL event_scheduler
sql/mysqld.cc:
--event-scheduler should be checked against a TYPELIB and
therefore should be GET_STR, as well as we make the parameter optional.
When not provided OFF|0 is used.
sql/set_var.cc:
Implement typelib for event_scheduler variable.
If allows both INT_RESULT -> 0 | 1
and STRING_RESULT -> OFF | ON
The variable is shown as DISABLED | ON | OFF
sql/set_var.h:
Implement typelib, which expects both STRING and INT,
for event_scheduler.
2006-09-01 13:08:44 +02:00
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
bool register_option(DYNAMIC_ARRAY *array, int parse_flags)
|
|
|
|
{
|
2014-08-27 16:05:54 +02:00
|
|
|
DBUG_ASSERT(parse_flags == GETOPT_ONLY_HELP ||
|
|
|
|
parse_flags == PARSE_EARLY || parse_flags == 0);
|
|
|
|
if (option.id == NO_GETOPT)
|
|
|
|
return 0;
|
|
|
|
if (parse_flags == GETOPT_ONLY_HELP)
|
|
|
|
{
|
|
|
|
if (option.id != GETOPT_ONLY_HELP)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (option.id == GETOPT_ONLY_HELP)
|
|
|
|
return 0;
|
|
|
|
if ((flags & PARSE_EARLY) != parse_flags)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return insert_dynamic(array, (uchar*)&option);
|
2010-01-07 06:42:07 +01:00
|
|
|
}
|
2013-09-05 10:10:27 +02:00
|
|
|
void do_deprecated_warning(THD *thd);
|
2015-04-09 11:14:57 +02:00
|
|
|
/**
|
|
|
|
whether session value of a sysvar is a default one.
|
|
|
|
|
|
|
|
in this simple implementation we don't distinguish between default
|
|
|
|
and non-default values. for most variables it's ok, they don't treat
|
|
|
|
default values specially. this method is overwritten in descendant
|
|
|
|
classes as necessary.
|
|
|
|
*/
|
|
|
|
virtual bool session_is_default(THD *thd) { return false; }
|
2005-12-06 16:15:29 +01:00
|
|
|
|
2014-09-03 20:16:51 +02:00
|
|
|
virtual uchar *default_value_ptr(THD *thd)
|
|
|
|
{ return (uchar*)&option.def_value; }
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
private:
|
|
|
|
virtual bool do_check(THD *thd, set_var *var) = 0;
|
|
|
|
/**
|
|
|
|
save the session default value of the variable in var
|
|
|
|
*/
|
|
|
|
virtual void session_save_default(THD *thd, set_var *var) = 0;
|
|
|
|
/**
|
|
|
|
save the global default value of the variable in var
|
|
|
|
*/
|
|
|
|
virtual void global_save_default(THD *thd, set_var *var) = 0;
|
|
|
|
virtual bool session_update(THD *thd, set_var *var) = 0;
|
|
|
|
virtual bool global_update(THD *thd, set_var *var) = 0;
|
2013-09-05 10:10:27 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
A pointer to a value of the variable for SHOW.
|
2014-09-03 20:05:51 +02:00
|
|
|
It must be of show_val_type type (my_bool for SHOW_MY_BOOL,
|
|
|
|
int for SHOW_INT, longlong for SHOW_LONGLONG, etc).
|
2009-12-22 10:35:56 +01:00
|
|
|
*/
|
2017-04-23 18:39:57 +02:00
|
|
|
virtual uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base);
|
|
|
|
virtual uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
mysql-test/r/rpl_row_4_bytes.result:
update
mysql-test/t/rpl_row_4_bytes.test:
don't influence next tests
sql/ha_archive.cc:
please pay attention to this structure when you change it...
sql/ha_berkeley.cc:
please pay attention to this structure when you change it...
sql/ha_blackhole.cc:
please pay attention to this structure when you change it...
sql/ha_federated.cc:
please pay attention to this structure when you change it...
sql/ha_heap.cc:
please pay attention to this structure when you change it...
sql/ha_innodb.cc:
please pay attention to this structure when you change it...
sql/ha_myisam.cc:
please pay attention to this structure when you change it...
sql/ha_myisammrg.cc:
please pay attention to this structure when you change it...
sql/ha_ndbcluster_binlog.cc:
no more global 'binlog_row_based'
sql/ha_partition.cc:
please pay attention to this structure when you change it...
sql/handler.cc:
please pay attention to this structure when you change it...
sql/handler.h:
it's good to initialize statically (to get no compiler warning) even if to a null value.
sql/item_func.cc:
UDFs require row-based if this is the "mixed" binlog format.
sql/item_strfunc.cc:
UUID() requires row-based binlogging if this is the "mixed" binlog format
sql/log.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log.h:
the enum enum_binlog_format moves to log.h from mysqld.cc as we need it in several places.
sql/log_event.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log_event.h:
this global variable not used anymore
sql/mysql_priv.h:
these global variables not used anymore
sql/mysqld.cc:
simplification in the handling of --binlog-format (but with no user-visible change), thanks to
the new global system variable.
RBR does not anymore turn on --log-bin-trust-function-creators and --innodb-locks-unsafe-for-binlog
as these are global options and RBR is now settable per session.
sql/partition_info.cc:
compiler warnings
sql/set_var.cc:
new class of thread's variable, to handle the binlog_format (like sys_var_thd_enum except
that is_readonly() is overriden for more checks before update).
compiler warnings (ok'd by Serg)
sql/set_var.h:
new class for the thread's binlog_format (see set_var.cc)
sql/share/errmsg.txt:
some messages for when one can't toggle from one binlog format to another
sql/sp_head.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_base.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_class.cc:
When a THD is initialized, we set its current_stmt_binlog_row_based
sql/sql_class.h:
new THD::variables.binlog_format (the value of the session variable set by SET
or inherited from the global value), and THD::current_stmt_binlog_row_based which tells if the
current statement does row-based or statement-based binlogging. Both members are needed
as the 2nd one cannot be derived only from the first one (the statement's type plays a role too),
and the 1st one is needed to reset the 2nd one.
sql/sql_delete.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_insert.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_load.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based.
sql/sql_parse.cc:
when we are done with a statement, we reset the current_stmt_binlog_row_based to the value
derived from THD::variables.binlog_format.
sql/sql_partition.cc:
compiler warning
sql/sql_show.cc:
compiler warning
sql/sql_table.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
tests/mysql_client_test.c:
compiler warning
mysql-test/r/ndb_binlog_basic2.result:
new result
mysql-test/r/rpl_switch_stm_row_mixed.result:
new result
mysql-test/t/ndb_binlog_basic2.test:
new test to verify that if cluster is enabled, can't change binlog format on the fly.
mysql-test/t/rpl_switch_stm_row_mixed.test:
test to see if one can switch between SBR, RBR, and "mixed" mode, and when one cannot,
and test to see if the switching, and the mixed mode, work properly (using UUID() to test,
as using UDFs is not possible in the testsuite for portability reasons).
2006-02-25 22:21:03 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
A pointer to a storage area of the variable, to the raw data.
|
|
|
|
Typically it's the same as session_value_ptr(), but it's different,
|
|
|
|
for example, for ENUM, that is printed as a string, but stored as a number.
|
|
|
|
*/
|
|
|
|
uchar *session_var_ptr(THD *thd)
|
|
|
|
{ return ((uchar*)&(thd->variables)) + offset; }
|
|
|
|
|
|
|
|
uchar *global_var_ptr()
|
|
|
|
{ return ((uchar*)&global_system_variables) + offset; }
|
2016-04-15 20:47:45 +02:00
|
|
|
|
2018-06-20 15:14:04 +02:00
|
|
|
void *max_var_ptr()
|
|
|
|
{
|
|
|
|
return scope() == SESSION ? (((uchar*)&max_system_variables) + offset) :
|
|
|
|
0;
|
|
|
|
}
|
|
|
|
|
2016-04-15 20:47:45 +02:00
|
|
|
friend class Session_sysvars_tracker;
|
|
|
|
friend class Session_tracker;
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
mysql-test/r/rpl_row_4_bytes.result:
update
mysql-test/t/rpl_row_4_bytes.test:
don't influence next tests
sql/ha_archive.cc:
please pay attention to this structure when you change it...
sql/ha_berkeley.cc:
please pay attention to this structure when you change it...
sql/ha_blackhole.cc:
please pay attention to this structure when you change it...
sql/ha_federated.cc:
please pay attention to this structure when you change it...
sql/ha_heap.cc:
please pay attention to this structure when you change it...
sql/ha_innodb.cc:
please pay attention to this structure when you change it...
sql/ha_myisam.cc:
please pay attention to this structure when you change it...
sql/ha_myisammrg.cc:
please pay attention to this structure when you change it...
sql/ha_ndbcluster_binlog.cc:
no more global 'binlog_row_based'
sql/ha_partition.cc:
please pay attention to this structure when you change it...
sql/handler.cc:
please pay attention to this structure when you change it...
sql/handler.h:
it's good to initialize statically (to get no compiler warning) even if to a null value.
sql/item_func.cc:
UDFs require row-based if this is the "mixed" binlog format.
sql/item_strfunc.cc:
UUID() requires row-based binlogging if this is the "mixed" binlog format
sql/log.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log.h:
the enum enum_binlog_format moves to log.h from mysqld.cc as we need it in several places.
sql/log_event.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log_event.h:
this global variable not used anymore
sql/mysql_priv.h:
these global variables not used anymore
sql/mysqld.cc:
simplification in the handling of --binlog-format (but with no user-visible change), thanks to
the new global system variable.
RBR does not anymore turn on --log-bin-trust-function-creators and --innodb-locks-unsafe-for-binlog
as these are global options and RBR is now settable per session.
sql/partition_info.cc:
compiler warnings
sql/set_var.cc:
new class of thread's variable, to handle the binlog_format (like sys_var_thd_enum except
that is_readonly() is overriden for more checks before update).
compiler warnings (ok'd by Serg)
sql/set_var.h:
new class for the thread's binlog_format (see set_var.cc)
sql/share/errmsg.txt:
some messages for when one can't toggle from one binlog format to another
sql/sp_head.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_base.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_class.cc:
When a THD is initialized, we set its current_stmt_binlog_row_based
sql/sql_class.h:
new THD::variables.binlog_format (the value of the session variable set by SET
or inherited from the global value), and THD::current_stmt_binlog_row_based which tells if the
current statement does row-based or statement-based binlogging. Both members are needed
as the 2nd one cannot be derived only from the first one (the statement's type plays a role too),
and the 1st one is needed to reset the 2nd one.
sql/sql_delete.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_insert.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_load.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based.
sql/sql_parse.cc:
when we are done with a statement, we reset the current_stmt_binlog_row_based to the value
derived from THD::variables.binlog_format.
sql/sql_partition.cc:
compiler warning
sql/sql_show.cc:
compiler warning
sql/sql_table.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
tests/mysql_client_test.c:
compiler warning
mysql-test/r/ndb_binlog_basic2.result:
new result
mysql-test/r/rpl_switch_stm_row_mixed.result:
new result
mysql-test/t/ndb_binlog_basic2.test:
new test to verify that if cluster is enabled, can't change binlog format on the fly.
mysql-test/t/rpl_switch_stm_row_mixed.test:
test to see if one can switch between SBR, RBR, and "mixed" mode, and when one cannot,
and test to see if the switching, and the mixed mode, work properly (using UUID() to test,
as using UDFs is not possible in the testsuite for portability reasons).
2006-02-25 22:21:03 +01:00
|
|
|
};
|
2005-12-06 16:15:29 +01:00
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_plugin.h" /* SHOW_HA_ROWS, SHOW_MY_BOOL */
|
|
|
|
|
2011-08-11 11:38:52 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Classes for parsing of the SET command
|
|
|
|
****************************************************************************/
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
A base class for everything that can be set with SET command.
|
|
|
|
It's similar to Items, an instance of this is created by the parser
|
|
|
|
for every assigmnent in SET (or elsewhere, e.g. in SELECT).
|
|
|
|
*/
|
2002-07-23 17:31:22 +02:00
|
|
|
class set_var_base :public Sql_alloc
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
set_var_base() {}
|
|
|
|
virtual ~set_var_base() {}
|
2009-12-22 10:35:56 +01:00
|
|
|
virtual int check(THD *thd)=0; /* To check privileges etc. */
|
|
|
|
virtual int update(THD *thd)=0; /* To set the value */
|
|
|
|
virtual int light_check(THD *thd) { return check(thd); } /* for PS */
|
2014-10-24 10:13:08 +02:00
|
|
|
virtual bool is_system() { return FALSE; }
|
2019-02-13 06:52:16 +01:00
|
|
|
/**
|
|
|
|
@returns whether this variable is @@@@optimizer_trace.
|
|
|
|
*/
|
|
|
|
virtual bool is_var_optimizer_trace() const { return false; }
|
2002-07-23 17:31:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
set_var_base descendant for assignments to the system variables.
|
|
|
|
*/
|
2002-07-23 17:31:22 +02:00
|
|
|
class set_var :public set_var_base
|
|
|
|
{
|
|
|
|
public:
|
2009-12-22 10:35:56 +01:00
|
|
|
sys_var *var; ///< system variable to be updated
|
|
|
|
Item *value; ///< the expression that provides the new value of the variable
|
2002-07-23 17:31:22 +02:00
|
|
|
enum_var_type type;
|
2009-12-22 10:35:56 +01:00
|
|
|
union ///< temp storage to hold a value between sys_var::check and ::update
|
|
|
|
{
|
2011-11-22 18:05:34 +01:00
|
|
|
ulonglong ulonglong_value; ///< for unsigned integer, set, enum sysvars
|
|
|
|
longlong longlong_value; ///< for signed integer
|
2009-12-22 10:35:56 +01:00
|
|
|
double double_value; ///< for Sys_var_double
|
|
|
|
plugin_ref plugin; ///< for Sys_var_plugin
|
2017-03-20 11:55:24 +01:00
|
|
|
plugin_ref *plugins; ///< for Sys_var_pluginlist
|
2009-12-22 10:35:56 +01:00
|
|
|
Time_zone *time_zone; ///< for Sys_var_tz
|
|
|
|
LEX_STRING string_value; ///< for Sys_var_charptr and others
|
2011-04-25 17:22:25 +02:00
|
|
|
const void *ptr; ///< for Sys_var_struct
|
2002-07-23 17:31:22 +02:00
|
|
|
} save_result;
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING base; /**< for structured variables, like keycache_name.variable_name */
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2015-08-11 09:18:38 +02:00
|
|
|
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);
|
2014-10-24 10:13:08 +02:00
|
|
|
virtual bool is_system() { return 1; }
|
2002-09-22 17:02:39 +02:00
|
|
|
int check(THD *thd);
|
|
|
|
int update(THD *thd);
|
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 light_check(THD *thd);
|
2019-02-13 06:52:16 +01:00
|
|
|
virtual bool is_var_optimizer_trace() const
|
|
|
|
{
|
|
|
|
extern sys_var *Sys_optimizer_trace_ptr;
|
|
|
|
return var == Sys_optimizer_trace_ptr;
|
|
|
|
}
|
2002-07-23 17:31:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* User variables like @my_own_variable */
|
|
|
|
class set_var_user: public set_var_base
|
|
|
|
{
|
|
|
|
Item_func_set_user_var *user_var_item;
|
|
|
|
public:
|
|
|
|
set_var_user(Item_func_set_user_var *item)
|
|
|
|
:user_var_item(item)
|
|
|
|
{}
|
2002-09-22 17:02:39 +02:00
|
|
|
int check(THD *thd);
|
|
|
|
int update(THD *thd);
|
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 light_check(THD *thd);
|
2002-07-23 17:31:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* For SET PASSWORD */
|
|
|
|
|
|
|
|
class set_var_password: public set_var_base
|
|
|
|
{
|
|
|
|
LEX_USER *user;
|
|
|
|
public:
|
2014-11-25 10:07:59 +01:00
|
|
|
set_var_password(LEX_USER *user_arg) :user(user_arg)
|
2002-07-23 17:31:22 +02:00
|
|
|
{}
|
2002-09-22 17:02:39 +02:00
|
|
|
int check(THD *thd);
|
|
|
|
int update(THD *thd);
|
2002-07-23 17:31:22 +02:00
|
|
|
};
|
|
|
|
|
2013-10-18 00:11:21 +02:00
|
|
|
/* For SET ROLE */
|
|
|
|
|
2014-01-28 21:02:17 +01:00
|
|
|
class set_var_role: public set_var_base
|
2013-10-18 00:11:21 +02:00
|
|
|
{
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING role;
|
2020-02-09 18:53:11 +01:00
|
|
|
privilege_t access;
|
2013-10-18 00:11:21 +02:00
|
|
|
public:
|
2020-02-09 18:53:11 +01:00
|
|
|
set_var_role(LEX_CSTRING role_arg) : role(role_arg), access(NO_ACL) {}
|
2013-10-18 00:11:21 +02:00
|
|
|
int check(THD *thd);
|
|
|
|
int update(THD *thd);
|
|
|
|
};
|
|
|
|
|
2014-07-14 01:57:10 +02:00
|
|
|
/* For SET DEFAULT ROLE */
|
|
|
|
|
|
|
|
class set_var_default_role: public set_var_base
|
|
|
|
{
|
2015-02-27 20:13:51 +01:00
|
|
|
LEX_USER *user, *real_user;
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING role;
|
2014-07-14 01:57:10 +02:00
|
|
|
public:
|
2017-04-23 18:39:57 +02:00
|
|
|
set_var_default_role(LEX_USER *user_arg, LEX_CSTRING role_arg) :
|
2014-07-14 01:57:10 +02:00
|
|
|
user(user_arg), role(role_arg) {}
|
|
|
|
int check(THD *thd);
|
|
|
|
int update(THD *thd);
|
|
|
|
};
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2003-04-05 12:59:29 +02:00
|
|
|
/* For SET NAMES and SET CHARACTER SET */
|
|
|
|
|
2003-04-23 15:19:22 +02:00
|
|
|
class set_var_collation_client: public set_var_base
|
2003-04-05 12:59:29 +02:00
|
|
|
{
|
2003-05-21 14:44:12 +02:00
|
|
|
CHARSET_INFO *character_set_client;
|
|
|
|
CHARSET_INFO *character_set_results;
|
2003-04-23 15:19:22 +02:00
|
|
|
CHARSET_INFO *collation_connection;
|
2003-04-05 12:59:29 +02:00
|
|
|
public:
|
2003-04-23 15:19:22 +02:00
|
|
|
set_var_collation_client(CHARSET_INFO *client_coll_arg,
|
2009-12-22 10:35:56 +01:00
|
|
|
CHARSET_INFO *connection_coll_arg,
|
|
|
|
CHARSET_INFO *result_coll_arg)
|
2003-05-21 14:44:12 +02:00
|
|
|
:character_set_client(client_coll_arg),
|
|
|
|
character_set_results(result_coll_arg),
|
|
|
|
collation_connection(connection_coll_arg)
|
2003-04-05 12:59:29 +02:00
|
|
|
{}
|
|
|
|
int check(THD *thd);
|
|
|
|
int update(THD *thd);
|
|
|
|
};
|
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
/* optional things, have_* variables */
|
|
|
|
extern SHOW_COMP_OPTION have_csv, have_innodb;
|
|
|
|
extern SHOW_COMP_OPTION have_ndbcluster, have_partitioning;
|
|
|
|
extern SHOW_COMP_OPTION have_profiling;
|
|
|
|
|
|
|
|
extern SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen;
|
|
|
|
extern SHOW_COMP_OPTION have_query_cache;
|
|
|
|
extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
|
|
|
|
extern SHOW_COMP_OPTION have_crypt;
|
|
|
|
extern SHOW_COMP_OPTION have_compress;
|
2012-12-18 11:56:00 +01:00
|
|
|
extern SHOW_COMP_OPTION have_openssl;
|
2010-03-31 16:05:33 +02:00
|
|
|
|
2002-07-23 17:31:22 +02:00
|
|
|
/*
|
|
|
|
Prototypes for helper functions
|
|
|
|
*/
|
2020-02-14 16:53:53 +01:00
|
|
|
ulong get_system_variable_hash_records(void);
|
|
|
|
ulonglong get_system_variable_hash_version(void);
|
2002-07-23 17:31:22 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted, enum enum_var_type type);
|
2014-09-03 20:16:51 +02:00
|
|
|
int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2019-03-20 21:42:48 +01:00
|
|
|
sys_var *find_sys_var(THD *thd, const char *str, size_t length= 0,
|
|
|
|
bool throw_error= false);
|
2014-10-24 10:13:08 +02:00
|
|
|
int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool free);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2014-09-03 15:16:43 +02:00
|
|
|
#define SYSVAR_AUTOSIZE(VAR,VAL) \
|
|
|
|
do { \
|
|
|
|
VAR= (VAL); \
|
2015-08-10 21:45:11 +02:00
|
|
|
set_sys_var_value_origin(&VAR, sys_var::AUTO); \
|
2014-09-03 15:16:43 +02:00
|
|
|
} while(0)
|
|
|
|
|
2018-03-22 19:03:54 +01:00
|
|
|
#define SYSVAR_AUTOSIZE_IF_CHANGED(VAR,VAL,TYPE) \
|
|
|
|
do { \
|
|
|
|
TYPE tmp= (VAL); \
|
|
|
|
if (VAR != tmp) \
|
|
|
|
{ \
|
|
|
|
VAR= (VAL); \
|
|
|
|
set_sys_var_value_origin(&VAR, sys_var::AUTO); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
2015-08-10 21:45:11 +02:00
|
|
|
void set_sys_var_value_origin(void *ptr, enum sys_var::where here);
|
|
|
|
|
|
|
|
enum sys_var::where get_sys_var_value_origin(void *ptr);
|
|
|
|
inline bool IS_SYSVAR_AUTOSIZE(void *ptr)
|
|
|
|
{
|
|
|
|
enum sys_var::where res= get_sys_var_value_origin(ptr);
|
|
|
|
return (res == sys_var::AUTO || res == sys_var::COMPILE_TIME);
|
|
|
|
}
|
2014-09-03 15:16:43 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type);
|
|
|
|
|
2016-10-02 15:39:40 +02:00
|
|
|
sql_mode_t expand_sql_mode(sql_mode_t sql_mode);
|
2019-08-26 13:28:32 +02:00
|
|
|
const char *sql_mode_string_representation(uint bit_number);
|
2017-04-23 18:39:57 +02:00
|
|
|
bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
|
|
|
|
LEX_CSTRING *ls);
|
2019-12-16 22:37:59 +01:00
|
|
|
int default_regex_flags_pcre(THD *thd);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2018-03-12 14:46:00 +01:00
|
|
|
extern sys_var *Sys_autocommit_ptr, *Sys_last_gtid_ptr,
|
|
|
|
*Sys_character_set_client_ptr, *Sys_character_set_connection_ptr,
|
|
|
|
*Sys_character_set_results_ptr;
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2003-04-05 15:56:15 +02:00
|
|
|
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
|
2003-07-06 18:09:57 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
int sys_var_init();
|
2016-04-28 10:28:02 +02:00
|
|
|
uint sys_var_elements();
|
2010-01-07 06:42:07 +01:00
|
|
|
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags);
|
2009-12-22 10:35:56 +01:00
|
|
|
void sys_var_end(void);
|
2018-06-13 07:57:15 +02:00
|
|
|
bool check_has_super(sys_var *self, THD *thd, set_var *var);
|
2017-04-20 16:19:01 +02:00
|
|
|
plugin_ref *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
|
|
|
void free_engine_list(plugin_ref *list);
|
|
|
|
plugin_ref *copy_engine_list(plugin_ref *list);
|
2017-04-20 16:19:01 +02:00
|
|
|
plugin_ref *temp_copy_engine_list(THD *thd, plugin_ref *list);
|
2017-03-20 11:55:24 +01:00
|
|
|
char *pretty_print_engine_list(THD *thd, plugin_ref *list);
|
2006-06-19 15:30:55 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
#endif
|