MDEV-5231: Per query variables from Percona Server (rewritten)

This commit is contained in:
Oleksandr Byelkin 2014-10-24 10:13:08 +02:00
parent a03dd94be8
commit 1827d9e6d1
29 changed files with 2681 additions and 61 deletions

View File

@ -218,13 +218,13 @@ drop event events_test.mysqltest_user1;
drop user mysqltest_user1@localhost; drop user mysqltest_user1@localhost;
drop database mysqltest_db1; drop database mysqltest_db1;
create event e_53 on schedule at (select s1 from ttx) do drop table t; create event e_53 on schedule at (select s1 from ttx) do drop table t;
ERROR 42000: This version of MariaDB doesn't yet support 'Usage of subqueries or stored function calls as part of this statement' ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions.
create event e_53 on schedule every (select s1 from ttx) second do drop table t; create event e_53 on schedule every (select s1 from ttx) second do drop table t;
ERROR 42000: This version of MariaDB doesn't yet support 'Usage of subqueries or stored function calls as part of this statement' ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions.
create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t; create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t;
ERROR 42000: This version of MariaDB doesn't yet support 'Usage of subqueries or stored function calls as part of this statement' ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions.
create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t; create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t;
ERROR 42000: This version of MariaDB doesn't yet support 'Usage of subqueries or stored function calls as part of this statement' ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions.
drop event if exists e_16; drop event if exists e_16;
drop procedure if exists p_16; drop procedure if exists p_16;
create event e_16 on schedule every 1 second do set @a=5; create event e_16 on schedule every 1 second do set @a=5;
@ -265,7 +265,7 @@ begin
call p22830_wait(); call p22830_wait();
select 123; select 123;
end| end|
ERROR 42000: This version of MariaDB doesn't yet support 'Usage of subqueries or stored function calls as part of this statement' ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions.
create event e22830_1 on schedule every 1 hour do create event e22830_1 on schedule every 1 hour do
begin begin
call p22830_wait(); call p22830_wait();

View File

@ -24,7 +24,7 @@ SELECT 4;
4 4
4 4
KILL (SELECT COUNT(*) FROM mysql.user); KILL (SELECT COUNT(*) FROM mysql.user);
ERROR 42000: This version of MariaDB doesn't yet support 'Usage of subqueries or stored function calls as part of this statement' ERROR 42000: KILL does not support subqueries or stored functions.
SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read WAIT_FOR kill'; SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read WAIT_FOR kill';
SET DEBUG_SYNC= 'now WAIT_FOR con1_read'; SET DEBUG_SYNC= 'now WAIT_FOR con1_read';

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
set @save_debug_dbug= @@debug_dbug;
set statement debug_dbug="d,something" for select @@debug_dbug;
@@debug_dbug
d,something
set @@debug_dbug= @save_debug_dbug;
CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
CALL mtr.add_suppression("Out of sort memory");
SET statement debug_dbug= '+d,alloc_sort_buffer_fail' for SELECT * FROM t1 ORDER BY f1 ASC, f0;
ERROR HY001: Out of sort memory, consider increasing server sort buffer size
SELECT * FROM t1 ORDER BY f1 ASC, f0;
f0 f1
1 0
2 1
3 2
4 3
5 4
6 5
DROP TABLE t1;
set @@debug_dbug= @save_debug_dbug;
set statement DEBUG_SYNC = 'now SIGNAL hi' for select 1;
ERROR 42000: The system variable debug_sync cannot be set in SET STATEMENT.

View File

@ -0,0 +1,4 @@
set statement profiling=default for select 1;
ERROR 42000: The system variable profiling cannot be set in SET STATEMENT.
set statement profiling_history_size=default for select 1;
ERROR 42000: The system variable profiling_history_size cannot be set in SET STATEMENT.

View File

@ -0,0 +1,31 @@
#Check if the variable is replicated correctly with "SET STATEMENT"
# Usage:
# $rpl_ssvt_var_name - the name of tested variable;
# $rpl_ssvt_var_value - the value to set;
# $rpl_ssvt_table - the table name to insert values.
--connection master
--echo [connection master]
eval SELECT @@$rpl_ssvt_var_name;
--connection slave
--echo [connection slave]
eval SELECT @@$rpl_ssvt_var_name;
--connection master
--echo [connection master]
--disable_result_log
eval SET STATEMENT $rpl_ssvt_var_name=$rpl_ssvt_var_value FOR
INSERT INTO $rpl_ssvt_table VALUES(@@$rpl_ssvt_var_name);
--enable_result_log
eval SELECT @@$rpl_ssvt_var_name;
--sync_slave_with_master
--echo [connection slave]
eval SELECT * FROM $rpl_ssvt_table;
eval SELECT @@$rpl_ssvt_var_name;
--connection master
--echo [connection master]
eval DELETE FROM $rpl_ssvt_table;

View File

@ -0,0 +1,140 @@
include/master-slave.inc
[connection master]
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
call mtr.add_suppression("Unsafe statement written to the binary log*");
CREATE TABLE t1 (a bigint unsigned not null);
CREATE TABLE t2 (a char(255) not null);
There are the following types of variables:
1) variables that are NOT replicated correctly when using STATEMENT mode;
[connection master]
SELECT @@max_join_size;
@@max_join_size
18446744073709551615
[connection slave]
SELECT @@max_join_size;
@@max_join_size
18446744073709551615
[connection master]
SET STATEMENT max_join_size=2 FOR
INSERT INTO t1 VALUES(@@max_join_size);
SELECT @@max_join_size;
@@max_join_size
18446744073709551615
[connection slave]
SELECT * FROM t1;
a
18446744073709551615
SELECT @@max_join_size;
@@max_join_size
18446744073709551615
[connection master]
DELETE FROM t1;
2) variables thar ARE replicated correctly
They must be replicated correctly with "SET STATEMENT" too.
[connection master]
SELECT @@auto_increment_increment;
@@auto_increment_increment
1
[connection slave]
SELECT @@auto_increment_increment;
@@auto_increment_increment
1
[connection master]
SET STATEMENT auto_increment_increment=10 FOR
INSERT INTO t1 VALUES(@@auto_increment_increment);
SELECT @@auto_increment_increment;
@@auto_increment_increment
1
[connection slave]
SELECT * FROM t1;
a
10
SELECT @@auto_increment_increment;
@@auto_increment_increment
1
[connection master]
DELETE FROM t1;
3) sql_mode which is replicated correctly exept NO_DIR_IN_CREATE value;
[connection master]
SELECT @@sql_mode;
@@sql_mode
[connection slave]
SELECT @@sql_mode;
@@sql_mode
[connection master]
SET STATEMENT sql_mode='ERROR_FOR_DIVISION_BY_ZERO' FOR
INSERT INTO t2 VALUES(@@sql_mode);
SELECT @@sql_mode;
@@sql_mode
[connection slave]
SELECT * FROM t2;
a
ERROR_FOR_DIVISION_BY_ZERO
SELECT @@sql_mode;
@@sql_mode
[connection master]
DELETE FROM t2;
[connection master]
SELECT @@sql_mode;
@@sql_mode
[connection slave]
SELECT @@sql_mode;
@@sql_mode
[connection master]
SET STATEMENT sql_mode='NO_DIR_IN_CREATE' FOR
INSERT INTO t2 VALUES(@@sql_mode);
SELECT @@sql_mode;
@@sql_mode
[connection slave]
SELECT * FROM t2;
a
SELECT @@sql_mode;
@@sql_mode
[connection master]
DELETE FROM t2;
4) variables that are not replicated at all:
default_storage_engine, storage_engine, max_heap_table_size
[connection master]
SELECT @@max_heap_table_size;
@@max_heap_table_size
1048576
[connection slave]
SELECT @@max_heap_table_size;
@@max_heap_table_size
1048576
[connection master]
SET STATEMENT max_heap_table_size=16384 FOR
INSERT INTO t1 VALUES(@@max_heap_table_size);
SELECT @@max_heap_table_size;
@@max_heap_table_size
1048576
[connection slave]
SELECT * FROM t1;
a
1048576
SELECT @@max_heap_table_size;
@@max_heap_table_size
1048576
[connection master]
DELETE FROM t1;
DROP TABLE t1;
DROP TABLE t2;
include/stop_slave.inc

View File

@ -0,0 +1,57 @@
--source include/master-slave.inc
--source include/have_binlog_format_statement.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings
call mtr.add_suppression("Unsafe statement written to the binary log*");
CREATE TABLE t1 (a bigint unsigned not null);
CREATE TABLE t2 (a char(255) not null);
--echo
--echo There are the following types of variables:
--echo 1) variables that are NOT replicated correctly when using STATEMENT mode;
--echo
--let $rpl_ssvt_var_name=max_join_size
--let $rpl_ssvt_var_value=2
--let $rpl_ssvt_table=t1
--source suite/rpl/include/rpl_set_statement.inc
--echo
--echo 2) variables thar ARE replicated correctly
--echo They must be replicated correctly with "SET STATEMENT" too.
--echo
--let $rpl_ssvt_var_name=auto_increment_increment
--let $rpl_ssvt_var_value=10
--let $rpl_ssvt_table=t1
--source suite/rpl/include/rpl_set_statement.inc
--echo
--echo 3) sql_mode which is replicated correctly exept NO_DIR_IN_CREATE value;
--echo
--let $rpl_ssvt_var_name=sql_mode
--let $rpl_ssvt_var_value='ERROR_FOR_DIVISION_BY_ZERO'
--let $rpl_ssvt_table=t2
--source suite/rpl/include/rpl_set_statement.inc
--let $rpl_ssvt_var_name=sql_mode
--let $rpl_ssvt_var_value='NO_DIR_IN_CREATE'
--let $rpl_ssvt_table=t2
--source suite/rpl/include/rpl_set_statement.inc
--echo
--echo 4) variables that are not replicated at all:
--echo default_storage_engine, storage_engine, max_heap_table_size
--echo
--let $rpl_ssvt_var_name=max_heap_table_size
--let $rpl_ssvt_var_value=16384
--let $rpl_ssvt_table=t1
--source suite/rpl/include/rpl_set_statement.inc
connection master;
DROP TABLE t1;
DROP TABLE t2;
sync_slave_with_master;
source include/stop_slave.inc;

View File

@ -508,13 +508,13 @@ drop database mysqltest_db1;
# #
# START - BUG#16394: Events: Crash if schedule contains SELECT # START - BUG#16394: Events: Crash if schedule contains SELECT
# #
--error ER_NOT_SUPPORTED_YET --error ER_SUBQUERIES_NOT_SUPPORTED
create event e_53 on schedule at (select s1 from ttx) do drop table t; create event e_53 on schedule at (select s1 from ttx) do drop table t;
--error ER_NOT_SUPPORTED_YET --error ER_SUBQUERIES_NOT_SUPPORTED
create event e_53 on schedule every (select s1 from ttx) second do drop table t; create event e_53 on schedule every (select s1 from ttx) second do drop table t;
--error ER_NOT_SUPPORTED_YET --error ER_SUBQUERIES_NOT_SUPPORTED
create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t; create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t;
--error ER_NOT_SUPPORTED_YET --error ER_SUBQUERIES_NOT_SUPPORTED
create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t; create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t;
# #
# END - BUG#16394: Events: Crash if schedule contains SELECT # END - BUG#16394: Events: Crash if schedule contains SELECT
@ -570,7 +570,7 @@ begin
select release_lock('ee_22830'); select release_lock('ee_22830');
end| end|
--error ER_NOT_SUPPORTED_YET --error ER_SUBQUERIES_NOT_SUPPORTED
create event e22830 on schedule every f22830() second do create event e22830 on schedule every f22830() second do
begin begin
call p22830_wait(); call p22830_wait();

View File

@ -70,7 +70,7 @@ connection con2;
SELECT 4; SELECT 4;
connection default; connection default;
--error ER_NOT_SUPPORTED_YET --error ER_SUBQUERIES_NOT_SUPPORTED
KILL (SELECT COUNT(*) FROM mysql.user); KILL (SELECT COUNT(*) FROM mysql.user);
connection con1; connection con1;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
--source include/have_debug.inc
--source include/have_debug_sync.inc
set @save_debug_dbug= @@debug_dbug;
# check that change debug_dbug visible in SELECT
set statement debug_dbug="d,something" for select @@debug_dbug;
set @@debug_dbug= @save_debug_dbug;
#check that change debug_dbug has influence of hooks...
CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
CALL mtr.add_suppression("Out of sort memory");
--error ER_OUT_OF_SORTMEMORY
SET statement debug_dbug= '+d,alloc_sort_buffer_fail' for SELECT * FROM t1 ORDER BY f1 ASC, f0;
# ... and works only for one statement
SELECT * FROM t1 ORDER BY f1 ASC, f0;
DROP TABLE t1;
set @@debug_dbug= @save_debug_dbug;
--error ER_SET_STATEMENT_NOT_SUPPORTED
set statement DEBUG_SYNC = 'now SIGNAL hi' for select 1;

View File

@ -0,0 +1,9 @@
source include/have_profiling.inc;
#
# Prohibited Variables
#
--error ER_SET_STATEMENT_NOT_SUPPORTED
set statement profiling=default for select 1;
--error ER_SET_STATEMENT_NOT_SUPPORTED
set statement profiling_history_size=default for select 1;

View File

@ -2819,6 +2819,16 @@ protected:
fixed= 1; fixed= 1;
} }
public: public:
Item_string(CHARSET_INFO *csi, const char *str_arg, uint length_arg)
: m_cs_specified(FALSE)
{
collation.set(csi, DERIVATION_COERCIBLE);
set_name(NULL, 0, system_charset_info);
decimals= NOT_FIXED_DEC;
fixed= 1;
str_value.copy(str_arg, length_arg, csi);
max_length= str_value.numchars() * csi->mbmaxlen;
}
// Constructors with the item name set from its value // Constructors with the item name set from its value
Item_string(const char *str, uint length, CHARSET_INFO *cs, Item_string(const char *str, uint length, CHARSET_INFO *cs,
Derivation dv, uint repertoire) Derivation dv, uint repertoire)
@ -2954,6 +2964,7 @@ public:
} }
return MYSQL_TYPE_STRING; // Not a temporal literal return MYSQL_TYPE_STRING; // Not a temporal literal
} }
}; };

View File

@ -5547,7 +5547,7 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command,
tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(name, tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(name,
new Item_null()))); new Item_null())));
/* Create the variable */ /* Create the variable */
if (sql_set_variables(thd, &tmp_var_list)) if (sql_set_variables(thd, &tmp_var_list, false))
{ {
thd->lex= sav_lex; thd->lex= sav_lex;
goto err; goto err;

View File

@ -567,6 +567,7 @@ static SYMBOL symbols[] = {
{ "START", SYM(START_SYM)}, { "START", SYM(START_SYM)},
{ "STARTING", SYM(STARTING)}, { "STARTING", SYM(STARTING)},
{ "STARTS", SYM(STARTS_SYM)}, { "STARTS", SYM(STARTS_SYM)},
{ "STATEMENT", SYM(STATEMENT_SYM)},
{ "STATS_AUTO_RECALC",SYM(STATS_AUTO_RECALC_SYM)}, { "STATS_AUTO_RECALC",SYM(STATS_AUTO_RECALC_SYM)},
{ "STATS_PERSISTENT", SYM(STATS_PERSISTENT_SYM)}, { "STATS_PERSISTENT", SYM(STATS_PERSISTENT_SYM)},
{ "STATS_SAMPLE_PAGES",SYM(STATS_SAMPLE_PAGES_SYM)}, { "STATS_SAMPLE_PAGES",SYM(STATS_SAMPLE_PAGES_SYM)},

View File

@ -147,7 +147,7 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
flags(flags_arg), show_val_type(show_val_type_arg), flags(flags_arg), show_val_type(show_val_type_arg),
guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func), guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func),
deprecation_substitute(substitute), deprecation_substitute(substitute),
is_os_charset(FALSE) is_os_charset(FALSE), default_val(FALSE)
{ {
/* /*
There is a limitation in handle_options() related to short options: There is a limitation in handle_options() related to short options:
@ -675,9 +675,10 @@ sys_var *intern_find_sys_var(const char *str, uint length)
-1 ERROR, message not sent -1 ERROR, message not sent
*/ */
int sql_set_variables(THD *thd, List<set_var_base> *var_list) int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool free)
{ {
int error; int error= 0;
bool was_error= thd->is_error();
List_iterator_fast<set_var_base> it(*var_list); List_iterator_fast<set_var_base> it(*var_list);
DBUG_ENTER("sql_set_variables"); DBUG_ENTER("sql_set_variables");
@ -687,7 +688,7 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
if ((error= var->check(thd))) if ((error= var->check(thd)))
goto err; goto err;
} }
if (!(error= MY_TEST(thd->is_error()))) if (was_error || !(error= MY_TEST(thd->is_error())))
{ {
it.rewind(); it.rewind();
while ((var= it++)) while ((var= it++))
@ -695,7 +696,8 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
} }
err: err:
free_underlaid_joins(thd, &thd->lex->select_lex); if (free)
free_underlaid_joins(thd, &thd->lex->select_lex);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
@ -788,6 +790,7 @@ int set_var::light_check(THD *thd)
*/ */
int set_var::update(THD *thd) int set_var::update(THD *thd)
{ {
var->set_is_default(value == 0);
return value ? var->update(thd, this) : var->set_default(thd, this); return value ? var->update(thd, this) : var->set_default(thd, this);
} }

View File

@ -61,7 +61,8 @@ public:
sys_var *next; sys_var *next;
LEX_CSTRING name; LEX_CSTRING name;
enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023, enum flag_enum { GLOBAL, SESSION, ONLY_SESSION, SCOPE_MASK=1023,
READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096 }; READONLY=1024, ALLOCATED=2048, PARSE_EARLY=4096,
NO_SET_STATEMENT=8192};
enum { NO_GETOPT=-1, GETOPT_ONLY_HELP=-2 }; enum { NO_GETOPT=-1, GETOPT_ONLY_HELP=-2 };
enum where { CONFIG, AUTO, SQL, COMPILE_TIME, ENV }; enum where { CONFIG, AUTO, SQL, COMPILE_TIME, ENV };
@ -87,6 +88,7 @@ protected:
on_update_function on_update; on_update_function on_update;
const char *const deprecation_substitute; const char *const deprecation_substitute;
bool is_os_charset; ///< true if the value is in character_set_filesystem bool is_os_charset; ///< true if the value is in character_set_filesystem
bool default_val;
public: public:
sys_var(sys_var_chain *chain, const char *name_arg, const char *comment, sys_var(sys_var_chain *chain, const char *name_arg, const char *comment,
@ -133,6 +135,7 @@ public:
that support the syntax @@keycache_name.variable_name that support the syntax @@keycache_name.variable_name
*/ */
bool is_struct() { return option.var_type & GET_ASK_ADDR; } bool is_struct() { return option.var_type & GET_ASK_ADDR; }
bool is_set_stmt_ok() const { return !(flags & NO_SET_STATEMENT); }
bool is_written_to_binlog(enum_var_type type) bool is_written_to_binlog(enum_var_type type)
{ return type != OPT_GLOBAL && binlog_status == SESSION_VARIABLE_IN_BINLOG; } { return type != OPT_GLOBAL && binlog_status == SESSION_VARIABLE_IN_BINLOG; }
bool check_update_type(Item_result type) bool check_update_type(Item_result type)
@ -191,6 +194,8 @@ public:
return insert_dynamic(array, (uchar*)&option); return insert_dynamic(array, (uchar*)&option);
} }
void do_deprecated_warning(THD *thd); void do_deprecated_warning(THD *thd);
bool is_default() { return default_val; }
void set_is_default(bool def) { default_val= def; }
virtual uchar *default_value_ptr(THD *thd) virtual uchar *default_value_ptr(THD *thd)
{ return (uchar*)&option.def_value; } { return (uchar*)&option.def_value; }
@ -249,6 +254,7 @@ public:
virtual int check(THD *thd)=0; /* To check privileges etc. */ virtual int check(THD *thd)=0; /* To check privileges etc. */
virtual int update(THD *thd)=0; /* To set the value */ virtual int update(THD *thd)=0; /* To set the value */
virtual int light_check(THD *thd) { return check(thd); } /* for PS */ virtual int light_check(THD *thd) { return check(thd); } /* for PS */
virtual bool is_system() { return FALSE; }
}; };
@ -290,6 +296,7 @@ public:
else else
value=value_arg; value=value_arg;
} }
virtual bool is_system() { return 1; }
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
int light_check(THD *thd); int light_check(THD *thd);
@ -388,7 +395,7 @@ SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted, enum enum_var_type type);
int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond); int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond);
sys_var *find_sys_var(THD *thd, const char *str, uint length=0); sys_var *find_sys_var(THD *thd, const char *str, uint length=0);
int sql_set_variables(THD *thd, List<set_var_base> *var_list); int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool free);
#define SYSVAR_AUTOSIZE(VAR,VAL) \ #define SYSVAR_AUTOSIZE(VAR,VAL) \
do { \ do { \

View File

@ -7111,3 +7111,7 @@ ER_TABLE_DEFINITION_TOO_BIG
eng "The definition for table %`s is too big" eng "The definition for table %`s is too big"
ER_STATEMENT_TIMEOUT 70100 ER_STATEMENT_TIMEOUT 70100
eng "Query execution was interrupted (max_statement_time exceeded)" eng "Query execution was interrupted (max_statement_time exceeded)"
ER_SUBQUERIES_NOT_SUPPORTED 42000
eng "%s does not support subqueries or stored functions."
ER_SET_STATEMENT_NOT_SUPPORTED 42000
eng "The system variable %.200s cannot be set in SET STATEMENT."

View File

@ -3441,6 +3441,7 @@ void Query_arena::free_items()
{ {
next= free_list->next; next= free_list->next;
DBUG_ASSERT(free_list != next); DBUG_ASSERT(free_list != next);
DBUG_PRINT("info", ("free item: 0x%lx", (ulong) free_list));
free_list->delete_self(); free_list->delete_self();
} }
/* Postcondition: free_list is 0 */ /* Postcondition: free_list is 0 */

View File

@ -3826,6 +3826,10 @@ public:
thr_timer_end(&query_timer); thr_timer_end(&query_timer);
#endif #endif
} }
void restore_set_statement_var()
{
main_lex.restore_set_statement_var();
}
}; };

View File

@ -542,6 +542,8 @@ void lex_start(THD *thd)
lex->reset_slave_info.all= false; lex->reset_slave_info.all= false;
lex->limit_rows_examined= 0; lex->limit_rows_examined= 0;
lex->limit_rows_examined_cnt= ULONGLONG_MAX; lex->limit_rows_examined_cnt= ULONGLONG_MAX;
lex->var_list.empty();
lex->stmt_var_list.empty();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -4233,6 +4235,17 @@ int LEX::print_explain(select_result_sink *output, uint8 explain_flags,
return res; return res;
} }
void LEX::restore_set_statement_var()
{
DBUG_ENTER("LEX::restore_set_statement_var");
if (!old_var_list.is_empty())
{
DBUG_PRINT("info", ("vars: %d", old_var_list.elements));
sql_set_variables(thd, &old_var_list, false);
old_var_list.empty();
}
DBUG_VOID_RETURN;
}
/* /*
Save explain structures of a UNION. The only variable member is whether the Save explain structures of a UNION. The only variable member is whether the

View File

@ -2401,6 +2401,8 @@ struct LEX: public Query_tables_list
List<Item> *insert_list,field_list,value_list,update_list; List<Item> *insert_list,field_list,value_list,update_list;
List<List_item> many_values; List<List_item> many_values;
List<set_var_base> var_list; List<set_var_base> var_list;
List<set_var_base> stmt_var_list; //SET_STATEMENT values
List<set_var_base> old_var_list; // SET STATEMENT old values
List<Item_func_set_user_var> set_var_list; // in-query assignment list List<Item_func_set_user_var> set_var_list; // in-query assignment list
List<Item_param> param_list; List<Item_param> param_list;
List<LEX_STRING> view_list; // view list (list of field names in view) List<LEX_STRING> view_list; // view list (list of field names in view)
@ -2775,6 +2777,7 @@ struct LEX: public Query_tables_list
int print_explain(select_result_sink *output, uint8 explain_flags, int print_explain(select_result_sink *output, uint8 explain_flags,
bool is_analyze, bool *printed_anything); bool is_analyze, bool *printed_anything);
void restore_set_statement_var();
}; };

View File

@ -2635,6 +2635,101 @@ mysql_execute_command(THD *thd)
thd->get_binlog_format(&orig_binlog_format, thd->get_binlog_format(&orig_binlog_format,
&orig_current_stmt_binlog_format); &orig_current_stmt_binlog_format);
if (!lex->stmt_var_list.is_empty() && !thd->slave_thread)
{
DBUG_PRINT("info", ("SET STATEMENT %d vars", lex->stmt_var_list.elements));
lex->old_var_list.empty();
List_iterator_fast<set_var_base> it(lex->stmt_var_list);
set_var_base *var;
while ((var=it++))
{
DBUG_ASSERT(var->is_system());
set_var *o= NULL, *v= (set_var*)var;
if (!v->var->is_set_stmt_ok())
{
my_error(ER_SET_STATEMENT_NOT_SUPPORTED, MYF(0), v->var->name.str);
goto error;
}
if (v->var->is_default())
o= new set_var(v->type, v->var, &v->base, NULL);
else
{
switch (v->var->option.var_type & GET_TYPE_MASK)
{
case GET_BOOL:
case GET_INT:
case GET_LONG:
case GET_LL:
{
bool null_value;
longlong val= v->var->val_int(&null_value, thd, v->type, &v->base);
o= new set_var(v->type, v->var, &v->base,
(null_value ?
(Item *)new Item_null() :
(Item *)new Item_int(val)));
}
break;
case GET_UINT:
case GET_ULONG:
case GET_ULL:
{
bool null_value;
ulonglong val= v->var->val_int(&null_value, thd, v->type, &v->base);
o= new set_var(v->type, v->var, &v->base,
(null_value ?
(Item *)new Item_null() :
(Item *)new Item_uint(val)));
}
break;
case GET_DOUBLE:
{
bool null_value;
double val= v->var->val_real(&null_value, thd, v->type, &v->base);
o= new set_var(v->type, v->var, &v->base,
(null_value ?
(Item *)new Item_null() :
(Item *)new Item_float(val, 1)));
}
break;
default:
case GET_NO_ARG:
case GET_DISABLED:
DBUG_ASSERT(0);
case 0:
case GET_FLAGSET:
case GET_ENUM:
case GET_SET:
case GET_STR:
case GET_STR_ALLOC:
{
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), v->var->charset(thd)),*val;
val= v->var->val_str(&tmp, thd, v->type, &v->base);
if (val)
{
Item_string *str= new Item_string(v->var->charset(thd),
val->ptr(), val->length());
o= new set_var(v->type, v->var, &v->base, str);
}
else
o= new set_var(v->type, v->var, &v->base, new Item_null());
}
break;
}
}
DBUG_ASSERT(o);
lex->old_var_list.push_back(o);
}
if (thd->is_error() ||
(res= sql_set_variables(thd, &lex->stmt_var_list, false)))
{
if (!thd->is_error())
my_error(ER_WRONG_ARGUMENTS, MYF(0), "SET");
goto error;
}
}
/* /*
Force statement logging for DDL commands to allow us to update Force statement logging for DDL commands to allow us to update
privilege, system or statistic tables directly without the updates privilege, system or statistic tables directly without the updates
@ -4100,7 +4195,7 @@ end_with_restore_list:
if ((check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE) if ((check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)
|| open_and_lock_tables(thd, all_tables, TRUE, 0))) || open_and_lock_tables(thd, all_tables, TRUE, 0)))
goto error; goto error;
if (!(res= sql_set_variables(thd, lex_var_list))) if (!(res= sql_set_variables(thd, lex_var_list, true)))
{ {
my_ok(thd); my_ok(thd);
} }
@ -4344,8 +4439,7 @@ end_with_restore_list:
DBUG_ASSERT(lex->event_parse_data); DBUG_ASSERT(lex->event_parse_data);
if (lex->table_or_sp_used()) if (lex->table_or_sp_used())
{ {
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored " my_error(ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "CREATE/ALTER EVENT");
"function calls as part of this statement");
break; break;
} }
@ -4665,8 +4759,7 @@ end_with_restore_list:
{ {
if (lex->table_or_sp_used()) if (lex->table_or_sp_used())
{ {
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored " my_error(ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "KILL");
"function calls as part of this statement");
break; break;
} }
@ -5059,6 +5152,7 @@ create_sp_error:
case SQLCOM_COMPOUND: case SQLCOM_COMPOUND:
DBUG_ASSERT(all_tables == 0); DBUG_ASSERT(all_tables == 0);
DBUG_ASSERT(thd->in_sub_stmt == 0); DBUG_ASSERT(thd->in_sub_stmt == 0);
lex->sphead->m_sql_mode= thd->variables.sql_mode;
if (do_execute_sp(thd, lex->sphead)) if (do_execute_sp(thd, lex->sphead))
goto error; goto error;
break; break;
@ -5482,6 +5576,8 @@ finish:
DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() || DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() ||
thd->in_multi_stmt_transaction_mode()); thd->in_multi_stmt_transaction_mode());
lex->restore_set_statement_var();
lex->unit.cleanup(); lex->unit.cleanup();
if (! thd->in_sub_stmt) if (! thd->in_sub_stmt)

View File

@ -189,4 +189,5 @@ extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
int type, uint state_mask, void *arg); int type, uint state_mask, void *arg);
extern bool plugin_dl_foreach(THD *thd, const LEX_STRING *dl, extern bool plugin_dl_foreach(THD *thd, const LEX_STRING *dl,
plugin_foreach_func *func, void *arg); plugin_foreach_func *func, void *arg);
#endif #endif

View File

@ -3299,7 +3299,7 @@ void Prepared_statement::cleanup_stmt()
{ {
DBUG_ENTER("Prepared_statement::cleanup_stmt"); DBUG_ENTER("Prepared_statement::cleanup_stmt");
DBUG_PRINT("enter",("stmt: 0x%lx", (long) this)); DBUG_PRINT("enter",("stmt: 0x%lx", (long) this));
thd->restore_set_statement_var();
cleanup_items(free_list); cleanup_items(free_list);
thd->cleanup_after_query(); thd->cleanup_after_query();
thd->rollback_item_tree_changes(); thd->rollback_item_tree_changes();
@ -3619,7 +3619,9 @@ Prepared_statement::execute_loop(String *expanded_query,
Reprepare_observer reprepare_observer; Reprepare_observer reprepare_observer;
bool error; bool error;
int reprepare_attempt= 0; int reprepare_attempt= 0;
#ifndef DBUG_OFF
Item *free_list_state= thd->free_list;
#endif
thd->select_number= select_number_after_prepare; thd->select_number= select_number_after_prepare;
/* Check if we got an error when sending long data */ /* Check if we got an error when sending long data */
if (state == Query_arena::STMT_ERROR) if (state == Query_arena::STMT_ERROR)
@ -3646,7 +3648,7 @@ reexecute:
allocated items when cleaning up after validation of the prepared allocated items when cleaning up after validation of the prepared
statement. statement.
*/ */
DBUG_ASSERT(thd->free_list == NULL); DBUG_ASSERT(thd->free_list == free_list_state);
/* /*
Install the metadata observer. If some metadata version is Install the metadata observer. If some metadata version is

View File

@ -256,7 +256,6 @@ static bool maybe_start_compound_statement(THD *thd)
Lex->sp_chistics.suid= SP_IS_NOT_SUID; Lex->sp_chistics.suid= SP_IS_NOT_SUID;
Lex->sphead->set_body_start(thd, YYLIP->get_cpp_ptr()); Lex->sphead->set_body_start(thd, YYLIP->get_cpp_ptr());
Lex->sphead->m_sql_mode= thd->variables.sql_mode;
} }
return 0; return 0;
} }
@ -788,8 +787,10 @@ static void sp_create_assignment_lex(THD *thd, bool no_lookahead)
lex->var_list.empty(); lex->var_list.empty();
lex->autocommit= 0; lex->autocommit= 0;
/* get_ptr() is only correct with no lookahead. */ /* get_ptr() is only correct with no lookahead. */
DBUG_ASSERT(no_lookahead); if (no_lookahead)
lex->sphead->m_tmp_query= lip->get_ptr(); lex->sphead->m_tmp_query= lip->get_ptr();
else
lex->sphead->m_tmp_query= lip->get_tok_end();
/* Inherit from outer lex. */ /* Inherit from outer lex. */
lex->option_type= old_lex->option_type; lex->option_type= old_lex->option_type;
} }
@ -932,10 +933,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd } %parse-param { THD *thd }
%lex-param { THD *thd } %lex-param { THD *thd }
/* /*
Currently there are 163 shift/reduce conflicts. Currently there are 164 shift/reduce conflicts.
We should not introduce new conflicts any more. We should not introduce new conflicts any more.
*/ */
%expect 163 %expect 164
/* /*
Comments for TOKENS. Comments for TOKENS.
@ -1481,6 +1482,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token STARTING %token STARTING
%token STARTS_SYM %token STARTS_SYM
%token START_SYM /* SQL-2003-R */ %token START_SYM /* SQL-2003-R */
%token STATEMENT_SYM
%token STATS_AUTO_RECALC_SYM %token STATS_AUTO_RECALC_SYM
%token STATS_PERSISTENT_SYM %token STATS_PERSISTENT_SYM
%token STATS_SAMPLE_PAGES_SYM %token STATS_SAMPLE_PAGES_SYM
@ -14321,6 +14323,7 @@ keyword_sp:
| SQL_NO_CACHE_SYM {} | SQL_NO_CACHE_SYM {}
| SQL_THREAD {} | SQL_THREAD {}
| STARTS_SYM {} | STARTS_SYM {}
| STATEMENT_SYM {}
| STATUS_SYM {} | STATUS_SYM {}
| STORAGE_SYM {} | STORAGE_SYM {}
| STRING_SYM {} | STRING_SYM {}
@ -14395,8 +14398,37 @@ set:
} }
start_option_value_list start_option_value_list
{} {}
| SET STATEMENT_SYM
{
LEX *lex= Lex;
mysql_init_select(lex);
lex->option_type= OPT_SESSION;
lex->sql_command= SQLCOM_SET_OPTION;
lex->autocommit= 0;
}
set_stmt_option_value_following_option_type_list
{
LEX *lex= Lex;
if (lex->table_or_sp_used())
{
my_error(ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "SET STATEMENT");
MYSQL_YYABORT;
}
lex->stmt_var_list= lex->var_list;
lex->var_list.empty();
}
FOR_SYM verb_clause
{}
; ;
set_stmt_option_value_following_option_type_list:
/*
Only system variables can be used here. If this condition is changed
please check careful code under lex->option_type == OPT_STATEMENT
condition on wrong type casts.
*/
option_value_following_option_type
| set_stmt_option_value_following_option_type_list ',' option_value_following_option_type
// Start of option value list // Start of option value list
start_option_value_list: start_option_value_list:

View File

@ -636,7 +636,7 @@ static bool fix_thd_charset(sys_var *self, THD *thd, enum_var_type type)
static Sys_var_struct Sys_character_set_client( static Sys_var_struct Sys_character_set_client(
"character_set_client", "The character set for statements " "character_set_client", "The character set for statements "
"that arrive from the client", "that arrive from the client",
SESSION_VAR(character_set_client), NO_CMD_LINE, NO_SET_STMT SESSION_VAR(character_set_client), NO_CMD_LINE,
offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_cs_client), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_cs_client),
ON_UPDATE(fix_thd_charset)); ON_UPDATE(fix_thd_charset));
@ -645,7 +645,7 @@ static Sys_var_struct Sys_character_set_connection(
"character_set_connection", "The character set used for " "character_set_connection", "The character set used for "
"literals that do not have a character set introducer and for " "literals that do not have a character set introducer and for "
"number-to-string conversion", "number-to-string conversion",
SESSION_VAR(collation_connection), NO_CMD_LINE, NO_SET_STMT SESSION_VAR(collation_connection), NO_CMD_LINE,
offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_not_null), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_not_null),
ON_UPDATE(fix_thd_charset)); ON_UPDATE(fix_thd_charset));
@ -659,7 +659,7 @@ static Sys_var_struct Sys_character_set_results(
static Sys_var_struct Sys_character_set_filesystem( static Sys_var_struct Sys_character_set_filesystem(
"character_set_filesystem", "The filesystem character set", "character_set_filesystem", "The filesystem character set",
SESSION_VAR(character_set_filesystem), NO_CMD_LINE, NO_SET_STMT SESSION_VAR(character_set_filesystem), NO_CMD_LINE,
offsetof(CHARSET_INFO, csname), DEFAULT(&character_set_filesystem), offsetof(CHARSET_INFO, csname), DEFAULT(&character_set_filesystem),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_charset_not_null), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_charset_not_null),
ON_UPDATE(fix_thd_charset)); ON_UPDATE(fix_thd_charset));
@ -705,7 +705,7 @@ static bool check_collation_not_null(sys_var *self, THD *thd, set_var *var)
static Sys_var_struct Sys_collation_connection( static Sys_var_struct Sys_collation_connection(
"collation_connection", "The collation of the connection " "collation_connection", "The collation of the connection "
"character set", "character set",
SESSION_VAR(collation_connection), NO_CMD_LINE, NO_SET_STMT SESSION_VAR(collation_connection), NO_CMD_LINE,
offsetof(CHARSET_INFO, name), DEFAULT(&default_charset_info), offsetof(CHARSET_INFO, name), DEFAULT(&default_charset_info),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_collation_not_null), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_collation_not_null),
ON_UPDATE(fix_thd_charset)); ON_UPDATE(fix_thd_charset));
@ -997,7 +997,7 @@ static bool check_master_connection(sys_var *self, THD *thd, set_var *var)
static Sys_var_session_lexstring Sys_default_master_connection( static Sys_var_session_lexstring Sys_default_master_connection(
"default_master_connection", "default_master_connection",
"Master connection to use for all slave variables and slave commands", "Master connection to use for all slave variables and slave commands",
SESSION_ONLY(default_master_connection), NO_SET_STMT SESSION_ONLY(default_master_connection),
NO_CMD_LINE, IN_SYSTEM_CHARSET, NO_CMD_LINE, IN_SYSTEM_CHARSET,
DEFAULT(""), MAX_CONNECTION_NAME, ON_CHECK(check_master_connection)); DEFAULT(""), MAX_CONNECTION_NAME, ON_CHECK(check_master_connection));
#endif #endif
@ -1024,7 +1024,7 @@ static Sys_var_ulong Sys_interactive_timeout(
"interactive_timeout", "interactive_timeout",
"The number of seconds the server waits for activity on an interactive " "The number of seconds the server waits for activity on an interactive "
"connection before closing it", "connection before closing it",
SESSION_VAR(net_interactive_timeout), NO_SET_STMT SESSION_VAR(net_interactive_timeout),
CMD_LINE(REQUIRED_ARG), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1)); VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1));
@ -1182,7 +1182,7 @@ static Sys_var_double Sys_long_query_time(
"Log all queries that have taken more than long_query_time seconds " "Log all queries that have taken more than long_query_time seconds "
"to execute to file. The argument will be treated as a decimal value " "to execute to file. The argument will be treated as a decimal value "
"with microsecond precision", "with microsecond precision",
SESSION_VAR(long_query_time_double), NO_SET_STMT SESSION_VAR(long_query_time_double),
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(10), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(10),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(update_cached_long_query_time)); ON_UPDATE(update_cached_long_query_time));
@ -1437,7 +1437,7 @@ static Sys_var_uint Sys_gtid_domain_id(
"parallel paths (for example multiple masters), each independent " "parallel paths (for example multiple masters), each independent "
"source server must use a distinct domain_id. For simple tree-shaped " "source server must use a distinct domain_id. For simple tree-shaped "
"replication topologies, it can be left at its default, 0.", "replication topologies, it can be left at its default, 0.",
SESSION_VAR(gtid_domain_id), NO_SET_STMT SESSION_VAR(gtid_domain_id),
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, UINT_MAX32), DEFAULT(0), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, UINT_MAX32), DEFAULT(0),
BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_gtid_domain_id)); ON_CHECK(check_gtid_domain_id));
@ -2037,7 +2037,7 @@ static Sys_var_ulong Sys_min_examined_row_limit(
"min_examined_row_limit", "min_examined_row_limit",
"Don't write queries to slow log that examine fewer rows " "Don't write queries to slow log that examine fewer rows "
"than that", "than that",
SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
#ifdef _WIN32 #ifdef _WIN32
@ -2130,8 +2130,9 @@ static bool check_old_passwords(sys_var *self, THD *thd, set_var *var)
static Sys_var_mybool Sys_old_passwords( static Sys_var_mybool Sys_old_passwords(
"old_passwords", "old_passwords",
"Use old password encryption method (needed for 4.0 and older clients)", "Use old password encryption method (needed for 4.0 and older clients)",
SESSION_VAR(old_passwords), CMD_LINE(OPT_ARG), DEFAULT(FALSE), NO_SET_STMT SESSION_VAR(old_passwords), CMD_LINE(OPT_ARG),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_old_passwords)); DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_old_passwords));
export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc
static Sys_var_ulong Sys_open_files_limit( static Sys_var_ulong Sys_open_files_limit(
@ -2675,7 +2676,7 @@ static Sys_var_enum Sys_query_cache_type(
"OFF = Don't cache or retrieve results. ON = Cache all results " "OFF = Don't cache or retrieve results. ON = Cache all results "
"except SELECT SQL_NO_CACHE ... queries. DEMAND = Cache only " "except SELECT SQL_NO_CACHE ... queries. DEMAND = Cache only "
"SELECT SQL_CACHE ... queries", "SELECT SQL_CACHE ... queries",
SESSION_VAR(query_cache_type), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(query_cache_type), CMD_LINE(REQUIRED_ARG),
query_cache_type_names, DEFAULT(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, query_cache_type_names, DEFAULT(1), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_query_cache_type), ON_CHECK(check_query_cache_type),
ON_UPDATE(fix_query_cache_type)); ON_UPDATE(fix_query_cache_type));
@ -3192,7 +3193,7 @@ static bool check_tx_isolation(sys_var *self, THD *thd, set_var *var)
// NO_CMD_LINE - different name of the option // NO_CMD_LINE - different name of the option
static Sys_var_tx_isolation Sys_tx_isolation( static Sys_var_tx_isolation Sys_tx_isolation(
"tx_isolation", "Default transaction isolation level", "tx_isolation", "Default transaction isolation level",
SESSION_VAR(tx_isolation), NO_CMD_LINE, NO_SET_STMT SESSION_VAR(tx_isolation), NO_CMD_LINE,
tx_isolation_names, DEFAULT(ISO_REPEATABLE_READ), tx_isolation_names, DEFAULT(ISO_REPEATABLE_READ),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_tx_isolation)); NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_tx_isolation));
@ -3284,7 +3285,7 @@ static Sys_var_ulong Sys_net_wait_timeout(
"wait_timeout", "wait_timeout",
"The number of seconds the server waits for activity on a " "The number of seconds the server waits for activity on a "
"connection before closing it", "connection before closing it",
SESSION_VAR(net_wait_timeout), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(net_wait_timeout), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)), VALID_RANGE(1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)),
DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1)); DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1));
@ -3321,7 +3322,7 @@ static Sys_var_plugin Sys_default_tmp_storage_engine(
*/ */
static Sys_var_debug_sync Sys_debug_sync( static Sys_var_debug_sync Sys_debug_sync(
"debug_sync", "Debug Sync Facility", "debug_sync", "Debug Sync Facility",
sys_var::ONLY_SESSION, NO_CMD_LINE, NO_SET_STMT sys_var::ONLY_SESSION, NO_CMD_LINE,
DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super)); DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super));
#endif /* defined(ENABLED_DEBUG_SYNC) */ #endif /* defined(ENABLED_DEBUG_SYNC) */
@ -3407,7 +3408,8 @@ static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type)
static Sys_var_bit Sys_autocommit( static Sys_var_bit Sys_autocommit(
"autocommit", "autocommit", "autocommit", "autocommit",
SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_AUTOCOMMIT, DEFAULT(TRUE), NO_SET_STMT SESSION_VAR(option_bits), NO_CMD_LINE,
OPTION_AUTOCOMMIT, DEFAULT(TRUE),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_autocommit)); NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_autocommit));
export sys_var *Sys_autocommit_ptr= &Sys_autocommit; // for sql_yacc.yy export sys_var *Sys_autocommit_ptr= &Sys_autocommit; // for sql_yacc.yy
@ -3423,7 +3425,7 @@ static Sys_var_bit Sys_big_selects(
static Sys_var_bit Sys_log_off( static Sys_var_bit Sys_log_off(
"sql_log_off", "sql_log_off", "sql_log_off", "sql_log_off",
SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_LOG_OFF, NO_SET_STMT SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_LOG_OFF,
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super)); DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super));
/** /**
@ -3527,12 +3529,12 @@ static Sys_var_bit Sys_unique_checks(
#ifdef ENABLED_PROFILING #ifdef ENABLED_PROFILING
static Sys_var_bit Sys_profiling( static Sys_var_bit Sys_profiling(
"profiling", "profiling", "profiling", "profiling",
SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_PROFILING, NO_SET_STMT SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_PROFILING,
DEFAULT(FALSE)); DEFAULT(FALSE));
static Sys_var_ulong Sys_profiling_history_size( static Sys_var_ulong Sys_profiling_history_size(
"profiling_history_size", "Limit of query profiling memory", "profiling_history_size", "Limit of query profiling memory",
SESSION_VAR(profiling_history_size), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(profiling_history_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 100), DEFAULT(15), BLOCK_SIZE(1)); VALID_RANGE(0, 100), DEFAULT(15), BLOCK_SIZE(1));
#endif #endif
@ -3566,7 +3568,8 @@ static bool check_skip_replication(sys_var *self, THD *thd, set_var *var)
static Sys_var_bit Sys_skip_replication( static Sys_var_bit Sys_skip_replication(
"skip_replication", "skip_replication", "skip_replication", "skip_replication",
SESSION_ONLY(option_bits), NO_CMD_LINE, OPTION_SKIP_REPLICATION, NO_SET_STMT SESSION_ONLY(option_bits),
NO_CMD_LINE, OPTION_SKIP_REPLICATION,
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_skip_replication)); ON_CHECK(check_skip_replication));
@ -3616,7 +3619,7 @@ static ulonglong read_last_insert_id(THD *thd)
} }
static Sys_var_session_special Sys_last_insert_id( static Sys_var_session_special Sys_last_insert_id(
"last_insert_id", "The value to be returned from LAST_INSERT_ID()", "last_insert_id", "The value to be returned from LAST_INSERT_ID()",
sys_var::ONLY_SESSION, NO_CMD_LINE, NO_SET_STMT sys_var::ONLY_SESSION, NO_CMD_LINE,
VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1), VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
ON_UPDATE(update_last_insert_id), ON_READ(read_last_insert_id)); ON_UPDATE(update_last_insert_id), ON_READ(read_last_insert_id));
@ -3688,7 +3691,7 @@ static ulonglong read_rand_seed(THD *thd)
static Sys_var_session_special Sys_rand_seed1( static Sys_var_session_special Sys_rand_seed1(
"rand_seed1", "Sets the internal state of the RAND() " "rand_seed1", "Sets the internal state of the RAND() "
"generator for replication purposes", "generator for replication purposes",
sys_var::ONLY_SESSION, NO_CMD_LINE, NO_SET_STMT sys_var::ONLY_SESSION, NO_CMD_LINE,
VALID_RANGE(0, ULONG_MAX), BLOCK_SIZE(1), VALID_RANGE(0, ULONG_MAX), BLOCK_SIZE(1),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
ON_UPDATE(update_rand_seed1), ON_READ(read_rand_seed)); ON_UPDATE(update_rand_seed1), ON_READ(read_rand_seed));
@ -3706,7 +3709,7 @@ static bool update_rand_seed2(THD *thd, set_var *var)
static Sys_var_session_special Sys_rand_seed2( static Sys_var_session_special Sys_rand_seed2(
"rand_seed2", "Sets the internal state of the RAND() " "rand_seed2", "Sets the internal state of the RAND() "
"generator for replication purposes", "generator for replication purposes",
sys_var::ONLY_SESSION, NO_CMD_LINE, NO_SET_STMT sys_var::ONLY_SESSION, NO_CMD_LINE,
VALID_RANGE(0, ULONG_MAX), BLOCK_SIZE(1), VALID_RANGE(0, ULONG_MAX), BLOCK_SIZE(1),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
ON_UPDATE(update_rand_seed2), ON_READ(read_rand_seed)); ON_UPDATE(update_rand_seed2), ON_READ(read_rand_seed));
@ -3738,7 +3741,7 @@ static Sys_var_session_special Sys_warning_count(
static Sys_var_ulong Sys_default_week_format( static Sys_var_ulong Sys_default_week_format(
"default_week_format", "default_week_format",
"The default week format used by WEEK() functions", "The default week format used by WEEK() functions",
SESSION_VAR(default_week_format), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(default_week_format), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 7), DEFAULT(0), BLOCK_SIZE(1)); VALID_RANGE(0, 7), DEFAULT(0), BLOCK_SIZE(1));
static Sys_var_ulonglong Sys_group_concat_max_len( static Sys_var_ulonglong Sys_group_concat_max_len(
@ -3961,7 +3964,7 @@ static Sys_var_mybool Sys_slow_query_log(
"Log slow queries to a table or log file. Defaults logging to a file " "Log slow queries to a table or log file. Defaults logging to a file "
"'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is "
"used. Must be enabled to activate other slow log options", "used. Must be enabled to activate other slow log options",
SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG), NO_SET_STMT SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG),
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(0), ON_UPDATE(fix_log_state)); ON_CHECK(0), ON_UPDATE(fix_log_state));
@ -4832,7 +4835,7 @@ static const char *log_slow_filter_names[]=
static Sys_var_set Sys_log_slow_filter( static Sys_var_set Sys_log_slow_filter(
"log_slow_filter", "log_slow_filter",
"Log only certain types of queries", "Log only certain types of queries",
SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG),
log_slow_filter_names, log_slow_filter_names,
DEFAULT(MAX_SET(array_elements(log_slow_filter_names)-1))); DEFAULT(MAX_SET(array_elements(log_slow_filter_names)-1)));
@ -4879,7 +4882,7 @@ static Sys_var_ulong Sys_log_slow_rate_limit(
"Write to slow log every #th slow query. Set to 1 to log everything. " "Write to slow log every #th slow query. Set to 1 to log everything. "
"Increase it to reduce the size of the slow or the performance impact " "Increase it to reduce the size of the slow or the performance impact "
"of slow logging", "of slow logging",
SESSION_VAR(log_slow_rate_limit), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(log_slow_rate_limit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, UINT_MAX), DEFAULT(1), BLOCK_SIZE(1)); VALID_RANGE(1, UINT_MAX), DEFAULT(1), BLOCK_SIZE(1));
static const char *log_slow_verbosity_names[]= { "innodb", "query_plan", static const char *log_slow_verbosity_names[]= { "innodb", "query_plan",
@ -4887,7 +4890,7 @@ static const char *log_slow_verbosity_names[]= { "innodb", "query_plan",
static Sys_var_set Sys_log_slow_verbosity( static Sys_var_set Sys_log_slow_verbosity(
"log_slow_verbosity", "log_slow_verbosity",
"Verbosity level for the slow log", "Verbosity level for the slow log",
SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG), NO_SET_STMT SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG),
log_slow_verbosity_names, DEFAULT(LOG_SLOW_VERBOSITY_INIT)); log_slow_verbosity_names, DEFAULT(LOG_SLOW_VERBOSITY_INIT));
static Sys_var_ulong Sys_join_cache_level( static Sys_var_ulong Sys_join_cache_level(

View File

@ -57,6 +57,7 @@
// this means that Sys_var_charptr initial value was malloc()ed // this means that Sys_var_charptr initial value was malloc()ed
#define PREALLOCATED sys_var::ALLOCATED+ #define PREALLOCATED sys_var::ALLOCATED+
#define PARSED_EARLY sys_var::PARSE_EARLY+ #define PARSED_EARLY sys_var::PARSE_EARLY+
#define NO_SET_STMT sys_var::NO_SET_STATEMENT+
/* /*
Sys_var_bit meaning is reversed, like in Sys_var_bit meaning is reversed, like in