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.
|
2020-06-02 09:25:11 +02:00
|
|
|
Copyright (c) 2009, 2020, MariaDB
|
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
|
Changing all cost calculation to be given in milliseconds
This makes it easier to compare different costs and also allows
the optimizer to optimizer different storage engines more reliably.
- Added tests/check_costs.pl, a tool to verify optimizer cost calculations.
- Most engine costs has been found with this program. All steps to
calculate the new costs are documented in Docs/optimizer_costs.txt
- User optimizer_cost variables are given in microseconds (as individual
costs can be very small). Internally they are stored in ms.
- Changed DISK_READ_COST (was DISK_SEEK_BASE_COST) from a hard disk cost
(9 ms) to common SSD cost (400MB/sec).
- Removed cost calculations for hard disks (rotation etc).
- Changed the following handler functions to return IO_AND_CPU_COST.
This makes it easy to apply different cost modifiers in ha_..time()
functions for io and cpu costs.
- scan_time()
- rnd_pos_time() & rnd_pos_call_time()
- keyread_time()
- Enhanched keyread_time() to calculate the full cost of reading of a set
of keys with a given number of ranges and optional number of blocks that
need to be accessed.
- Removed read_time() as keyread_time() + rnd_pos_time() can do the same
thing and more.
- Tuned cost for: heap, myisam, Aria, InnoDB, archive and MyRocks.
Used heap table costs for json_table. The rest are using default engine
costs.
- Added the following new optimizer variables:
- optimizer_disk_read_ratio
- optimizer_disk_read_cost
- optimizer_key_lookup_cost
- optimizer_row_lookup_cost
- optimizer_row_next_find_cost
- optimizer_scan_cost
- Moved all engine specific cost to OPTIMIZER_COSTS structure.
- Changed costs to use 'records_out' instead of 'records_read' when
recalculating costs.
- Split optimizer_costs.h to optimizer_costs.h and optimizer_defaults.h.
This allows one to change costs without having to compile a lot of
files.
- Updated costs for filter lookup.
- Use a better cost estimate in best_extension_by_limited_search()
for the sorting cost.
- Fixed previous issues with 'filtered' explain column as we are now
using 'records_out' (min rows seen for table) to calculate filtering.
This greatly simplifies the filtering code in
JOIN_TAB::save_explain_data().
This change caused a lot of queries to be optimized differently than
before, which exposed different issues in the optimizer that needs to
be fixed. These fixes are in the following commits. To not have to
change the same test case over and over again, the changes in the test
cases are done in a single commit after all the critical change sets
are done.
InnoDB changes:
- Updated InnoDB to not divide big range cost with 2.
- Added cost for InnoDB (innobase_update_optimizer_costs()).
- Don't mark clustered primary key with HA_KEYREAD_ONLY. This will
prevent that the optimizer is trying to use index-only scans on
the clustered key.
- Disabled ha_innobase::scan_time() and ha_innobase::read_time() and
ha_innobase::rnd_pos_time() as the default engine cost functions now
works good for InnoDB.
Other things:
- Added --show-query-costs (\Q) option to mysql.cc to show the query
cost after each query (good when working with query costs).
- Extended my_getopt with GET_ADJUSTED_VALUE which allows one to adjust
the value that user is given. This is used to change cost from
microseconds (user input) to milliseconds (what the server is
internally using).
- Added include/my_tracker.h ; Useful include file to quickly test
costs of a function.
- Use handler::set_table() in all places instead of 'table= arg'.
- Added SHOW_OPTIMIZER_COSTS to sys variables. These are input and
shown in microseconds for the user but stored as milliseconds.
This is to make the numbers easier to read for the user (less
pre-zeros). Implemented in 'Sys_var_optimizer_cost' class.
- In test_quick_select() do not use index scans if 'no_keyread' is set
for the table. This is what we do in other places of the server.
- Added THD parameter to Unique::get_use_cost() and
check_index_intersect_extension() and similar functions to be able
to provide costs to called functions.
- Changed 'records' to 'rows' in optimizer_trace.
- Write more information to optimizer_trace.
- Added INDEX_BLOCK_FILL_FACTOR_MUL (4) and INDEX_BLOCK_FILL_FACTOR_DIV (3)
to calculate usage space of keys in b-trees. (Before we used numeric
constants).
- Removed code that assumed that b-trees has similar costs as binary
trees. Replaced with engine calls that returns the cost.
- Added Bitmap::find_first_bit()
- Added timings to join_cache for ANALYZE table (patch by Sergei Petrunia).
- Added records_init and records_after_filter to POSITION to remember
more of what best_access_patch() calculates.
- table_after_join_selectivity() changed to recalculate 'records_out'
based on the new fields from best_access_patch()
Bug fixes:
- Some queries did not update last_query_cost (was 0). Fixed by moving
setting thd->...last_query_cost in JOIN::optimize().
- Write '0' as number of rows for const tables with a matching row.
Some internals:
- Engine cost are stored in OPTIMIZER_COSTS structure. When a
handlerton is created, we also created a new cost variable for the
handlerton. We also create a new variable if the user changes a
optimizer cost for a not yet loaded handlerton either with command
line arguments or with SET
@@global.engine.optimizer_cost_variable=xx.
- There are 3 global OPTIMIZER_COSTS variables:
default_optimizer_costs The default costs + changes from the
command line without an engine specifier.
heap_optimizer_costs Heap table costs, used for temporary tables
tmp_table_optimizer_costs The cost for the default on disk internal
temporary table (MyISAM or Aria)
- The engine cost for a table is stored in table_share. To speed up
accesses the handler has a pointer to this. The cost is copied
to the table on first access. If one wants to change the cost one
must first update the global engine cost and then do a FLUSH TABLES.
This was done to be able to access the costs for an open table
without any locks.
- When a handlerton is created, the cost are updated the following way:
See sql/keycaches.cc for details:
- Use 'default_optimizer_costs' as a base
- Call hton->update_optimizer_costs() to override with the engines
default costs.
- Override the costs that the user has specified for the engine.
- One handler open, copy the engine cost from handlerton to TABLE_SHARE.
- Call handler::update_optimizer_costs() to allow the engine to update
cost for this particular table.
- There are two costs stored in THD. These are copied to the handler
when the table is used in a query:
- optimizer_where_cost
- optimizer_scan_setup_cost
- Simply code in best_access_path() by storing all cost result in a
structure. (Idea/Suggestion by Igor)
2022-08-11 12:05:23 +02:00
|
|
|
SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc
|
2009-12-22 10:35:56 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
2023-02-07 12:57:20 +01:00
|
|
|
virtual ~sys_var() = default;
|
2010-09-09 14:37:09 +02:00
|
|
|
|
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);
|
2019-07-17 19:15:55 +02:00
|
|
|
const uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base) const;
|
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
|
|
|
|
2019-07-17 19:15:55 +02:00
|
|
|
SHOW_TYPE show_type() const { return show_val_type; }
|
2009-12-22 10:35:56 +01:00
|
|
|
int scope() const { return flags & SCOPE_MASK; }
|
2020-03-13 12:22:02 +01:00
|
|
|
virtual CHARSET_INFO *charset(THD *thd) const
|
|
|
|
{
|
2023-04-26 13:27:01 +02:00
|
|
|
return system_charset_info_for_i_s;
|
2020-03-13 12:22:02 +01:00
|
|
|
}
|
2009-12-22 10:35:56 +01:00
|
|
|
bool is_readonly() const { return flags & READONLY; }
|
2022-12-09 10:27:55 +01:00
|
|
|
void update_flags(int new_flags) { flags = new_flags; }
|
|
|
|
int get_flags() const { return flags; }
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
|
|
|
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
|
|
|
|
2019-07-17 19:15:55 +02:00
|
|
|
virtual const uchar *default_value_ptr(THD *thd) const
|
2014-09-03 20:16:51 +02:00
|
|
|
{ return (uchar*)&option.def_value; }
|
|
|
|
|
2020-03-17 08:08:00 +01:00
|
|
|
virtual bool on_check_access_global(THD *thd) const;
|
|
|
|
virtual bool on_check_access_session(THD *thd) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2019-07-17 19:15:55 +02:00
|
|
|
virtual const uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base) const;
|
|
|
|
virtual const uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base) const;
|
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.
|
|
|
|
*/
|
2019-07-17 19:15:55 +02:00
|
|
|
uchar *session_var_ptr(THD *thd) const
|
2009-12-22 10:35:56 +01:00
|
|
|
{ return ((uchar*)&(thd->variables)) + offset; }
|
|
|
|
|
2019-07-17 19:15:55 +02:00
|
|
|
uchar *global_var_ptr() const
|
2009-12-22 10:35:56 +01:00
|
|
|
{ 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:
|
2023-02-07 12:57:20 +01:00
|
|
|
set_var_base() = default;
|
|
|
|
virtual ~set_var_base() = default;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-07-18 15:11:16 +02:00
|
|
|
/**
|
|
|
|
Structure for holding unix timestamp and high precision second part.
|
|
|
|
*/
|
|
|
|
typedef struct my_time_t_hires
|
|
|
|
{
|
|
|
|
my_time_t unix_time;
|
|
|
|
ulong second_part;
|
|
|
|
} my_time_t_hires;
|
|
|
|
|
|
|
|
|
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
|
2019-07-18 15:11:16 +02:00
|
|
|
my_time_t_hires timestamp; ///< for Sys_var_vers_asof
|
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);
|
2024-06-12 15:46:26 +02:00
|
|
|
bool is_system() override { return 1; }
|
|
|
|
int check(THD *thd) override;
|
|
|
|
int update(THD *thd) override;
|
|
|
|
int light_check(THD *thd) override;
|
|
|
|
bool is_var_optimizer_trace() const override
|
2019-02-13 06:52:16 +01:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{}
|
2024-06-12 15:46:26 +02:00
|
|
|
int check(THD *thd) override;
|
|
|
|
int update(THD *thd) override;
|
|
|
|
int light_check(THD *thd) override;
|
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
|
|
|
{}
|
2024-06-12 15:46:26 +02:00
|
|
|
int check(THD *thd) override;
|
|
|
|
int update(THD *thd) override;
|
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) {}
|
2024-06-12 15:46:26 +02:00
|
|
|
int check(THD *thd) override;
|
|
|
|
int update(THD *thd) override;
|
2013-10-18 00:11:21 +02:00
|
|
|
};
|
|
|
|
|
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;
|
2023-04-26 13:27:01 +02:00
|
|
|
LEX_CSTRING real_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) {}
|
2024-06-12 15:46:26 +02:00
|
|
|
int check(THD *thd) override;
|
|
|
|
int update(THD *thd) override;
|
2014-07-14 01:57:10 +02:00
|
|
|
};
|
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
|
|
|
{}
|
2024-06-12 15:46:26 +02:00
|
|
|
int check(THD *thd) override;
|
|
|
|
int update(THD *thd) override;
|
2003-04-05 12:59:29 +02:00
|
|
|
};
|
|
|
|
|
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)
|
|
|
|
|
2021-12-24 22:16:10 +01:00
|
|
|
void set_sys_var_value_origin(void *ptr, enum sys_var::where here,
|
|
|
|
const char *filename= NULL);
|
2015-08-10 21:45:11 +02:00
|
|
|
|
|
|
|
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);
|
2023-10-24 07:07:07 +02:00
|
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
|
bool validate_redirect_url(char *str, size_t len);
|
|
|
|
#endif
|
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
|
|
|
|
2023-04-26 13:27:01 +02:00
|
|
|
CHARSET_INFO *get_old_charset_by_name(const LEX_CSTRING &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);
|
2009-12-22 10:35:56 +01:00
|
|
|
#endif
|