Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1827d9e6
Commit
1827d9e6
authored
Oct 24, 2014
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-5231: Per query variables from Percona Server (rewritten)
parent
a03dd94b
Changes
29
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
2681 additions
and
61 deletions
+2681
-61
mysql-test/r/events_bugs.result
mysql-test/r/events_bugs.result
+5
-5
mysql-test/r/kill.result
mysql-test/r/kill.result
+1
-1
mysql-test/r/set_statement.result
mysql-test/r/set_statement.result
+1102
-0
mysql-test/r/set_statement_debug.result
mysql-test/r/set_statement_debug.result
+22
-0
mysql-test/r/set_statement_profiling.result
mysql-test/r/set_statement_profiling.result
+4
-0
mysql-test/suite/rpl/include/rpl_set_statement.inc
mysql-test/suite/rpl/include/rpl_set_statement.inc
+31
-0
mysql-test/suite/rpl/r/rpl_set_statement.result
mysql-test/suite/rpl/r/rpl_set_statement.result
+140
-0
mysql-test/suite/rpl/t/rpl_set_statement.test
mysql-test/suite/rpl/t/rpl_set_statement.test
+57
-0
mysql-test/t/events_bugs.test
mysql-test/t/events_bugs.test
+5
-5
mysql-test/t/kill.test
mysql-test/t/kill.test
+1
-1
mysql-test/t/set_statement.test
mysql-test/t/set_statement.test
+1049
-0
mysql-test/t/set_statement_debug.test
mysql-test/t/set_statement_debug.test
+24
-0
mysql-test/t/set_statement_profiling.test
mysql-test/t/set_statement_profiling.test
+9
-0
sql/item.h
sql/item.h
+11
-0
sql/item_func.cc
sql/item_func.cc
+1
-1
sql/lex.h
sql/lex.h
+1
-0
sql/set_var.cc
sql/set_var.cc
+8
-5
sql/set_var.h
sql/set_var.h
+9
-2
sql/share/errmsg-utf8.txt
sql/share/errmsg-utf8.txt
+4
-0
sql/sql_class.cc
sql/sql_class.cc
+1
-0
sql/sql_class.h
sql/sql_class.h
+4
-0
sql/sql_lex.cc
sql/sql_lex.cc
+13
-0
sql/sql_lex.h
sql/sql_lex.h
+3
-0
sql/sql_parse.cc
sql/sql_parse.cc
+101
-5
sql/sql_plugin.h
sql/sql_plugin.h
+1
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+5
-3
sql/sql_yacc.yy
sql/sql_yacc.yy
+37
-5
sql/sys_vars.cc
sql/sys_vars.cc
+31
-28
sql/sys_vars.h
sql/sys_vars.h
+1
-0
No files found.
mysql-test/r/events_bugs.result
View file @
1827d9e6
...
...
@@ -218,13 +218,13 @@ drop event events_test.mysqltest_user1;
drop user mysqltest_user1@localhost;
drop database mysqltest_db1;
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;
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;
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;
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 procedure if exists p_16;
create event e_16 on schedule every 1 second do set @a=5;
...
...
@@ -265,7 +265,7 @@ begin
call p22830_wait();
select 123;
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
begin
call p22830_wait();
...
...
mysql-test/r/kill.result
View file @
1827d9e6
...
...
@@ -24,7 +24,7 @@ SELECT 4;
4
4
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= 'before_do_command_net_read SIGNAL con1_read WAIT_FOR kill';
SET DEBUG_SYNC= 'now WAIT_FOR con1_read';
...
...
mysql-test/r/set_statement.result
0 → 100644
View file @
1827d9e6
This diff is collapsed.
Click to expand it.
mysql-test/r/set_statement_debug.result
0 → 100644
View file @
1827d9e6
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.
mysql-test/r/set_statement_profiling.result
0 → 100644
View file @
1827d9e6
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.
mysql-test/suite/rpl/include/rpl_set_statement.inc
0 → 100644
View file @
1827d9e6
#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
;
mysql-test/suite/rpl/r/rpl_set_statement.result
0 → 100644
View file @
1827d9e6
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
mysql-test/suite/rpl/t/rpl_set_statement.test
0 → 100644
View file @
1827d9e6
--
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
;
mysql-test/t/events_bugs.test
View file @
1827d9e6
...
...
@@ -508,13 +508,13 @@ drop database mysqltest_db1;
#
# 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
;
--
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
;
--
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
;
--
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
;
#
# END - BUG#16394: Events: Crash if schedule contains SELECT
...
...
@@ -570,7 +570,7 @@ begin
select
release_lock
(
'ee_22830'
);
end
|
--
error
ER_
NOT_SUPPORTED_YET
--
error
ER_
SUBQUERIES_NOT_SUPPORTED
create
event
e22830
on
schedule
every
f22830
()
second
do
begin
call
p22830_wait
();
...
...
mysql-test/t/kill.test
View file @
1827d9e6
...
...
@@ -70,7 +70,7 @@ connection con2;
SELECT
4
;
connection
default
;
--
error
ER_
NOT_SUPPORTED_YET
--
error
ER_
SUBQUERIES_NOT_SUPPORTED
KILL
(
SELECT
COUNT
(
*
)
FROM
mysql
.
user
);
connection
con1
;
...
...
mysql-test/t/set_statement.test
0 → 100644
View file @
1827d9e6
This diff is collapsed.
Click to expand it.
mysql-test/t/set_statement_debug.test
0 → 100644
View file @
1827d9e6
--
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
;
mysql-test/t/set_statement_profiling.test
0 → 100644
View file @
1827d9e6
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
;
sql/item.h
View file @
1827d9e6
...
...
@@ -2819,6 +2819,16 @@ protected:
fixed
=
1
;
}
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
Item_string
(
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
Derivation
dv
,
uint
repertoire
)
...
...
@@ -2954,6 +2964,7 @@ public:
}
return
MYSQL_TYPE_STRING
;
// Not a temporal literal
}
};
...
...
sql/item_func.cc
View file @
1827d9e6
...
...
@@ -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
,
new
Item_null
())));
/* Create the variable */
if
(
sql_set_variables
(
thd
,
&
tmp_var_list
))
if
(
sql_set_variables
(
thd
,
&
tmp_var_list
,
false
))
{
thd
->
lex
=
sav_lex
;
goto
err
;
...
...
sql/lex.h
View file @
1827d9e6
...
...
@@ -567,6 +567,7 @@ static SYMBOL symbols[] = {
{
"START"
,
SYM
(
START_SYM
)},
{
"STARTING"
,
SYM
(
STARTING
)},
{
"STARTS"
,
SYM
(
STARTS_SYM
)},
{
"STATEMENT"
,
SYM
(
STATEMENT_SYM
)},
{
"STATS_AUTO_RECALC"
,
SYM
(
STATS_AUTO_RECALC_SYM
)},
{
"STATS_PERSISTENT"
,
SYM
(
STATS_PERSISTENT_SYM
)},
{
"STATS_SAMPLE_PAGES"
,
SYM
(
STATS_SAMPLE_PAGES_SYM
)},
...
...
sql/set_var.cc
View file @
1827d9e6
...
...
@@ -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
),
guard
(
lock
),
offset
(
off
),
on_check
(
on_check_func
),
on_update
(
on_update_func
),
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:
...
...
@@ -675,9 +675,10 @@ sys_var *intern_find_sys_var(const char *str, uint length)
-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
);
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
)))
goto
err
;
}
if
(
!
(
error
=
MY_TEST
(
thd
->
is_error
())))
if
(
was_error
||
!
(
error
=
MY_TEST
(
thd
->
is_error
())))
{
it
.
rewind
();
while
((
var
=
it
++
))
...
...
@@ -695,6 +696,7 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
}
err:
if
(
free
)
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
error
);
}
...
...
@@ -788,6 +790,7 @@ int set_var::light_check(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
);
}
...
...
sql/set_var.h
View file @
1827d9e6
...
...
@@ -61,7 +61,8 @@ public:
sys_var
*
next
;
LEX_CSTRING
name
;
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
where
{
CONFIG
,
AUTO
,
SQL
,
COMPILE_TIME
,
ENV
};
...
...
@@ -87,6 +88,7 @@ protected:
on_update_function
on_update
;
const
char
*
const
deprecation_substitute
;
bool
is_os_charset
;
///< true if the value is in character_set_filesystem
bool
default_val
;
public:
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
*/
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
)
{
return
type
!=
OPT_GLOBAL
&&
binlog_status
==
SESSION_VARIABLE_IN_BINLOG
;
}
bool
check_update_type
(
Item_result
type
)
...
...
@@ -191,6 +194,8 @@ public:
return
insert_dynamic
(
array
,
(
uchar
*
)
&
option
);
}
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
)
{
return
(
uchar
*
)
&
option
.
def_value
;
}
...
...
@@ -249,6 +254,7 @@ public:
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 */
virtual
bool
is_system
()
{
return
FALSE
;
}
};
...
...
@@ -290,6 +296,7 @@ public:
else
value
=
value_arg
;
}
virtual
bool
is_system
()
{
return
1
;
}
int
check
(
THD
*
thd
);
int
update
(
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
);
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) \
do { \
...
...
sql/share/errmsg-utf8.txt
View file @
1827d9e6
...
...
@@ -7111,3 +7111,7 @@ ER_TABLE_DEFINITION_TOO_BIG
eng "The definition for table %`s is too big"
ER_STATEMENT_TIMEOUT 70100
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."
sql/sql_class.cc
View file @
1827d9e6
...
...
@@ -3441,6 +3441,7 @@ void Query_arena::free_items()
{
next
=
free_list
->
next
;
DBUG_ASSERT
(
free_list
!=
next
);
DBUG_PRINT
(
"info"
,
(
"free item: 0x%lx"
,
(
ulong
)
free_list
));
free_list
->
delete_self
();
}
/* Postcondition: free_list is 0 */
...
...
sql/sql_class.h
View file @
1827d9e6
...
...
@@ -3826,6 +3826,10 @@ public:
thr_timer_end
(
&
query_timer
);
#endif
}
void
restore_set_statement_var
()
{
main_lex
.
restore_set_statement_var
();
}
}
;
...
...
sql/sql_lex.cc
View file @
1827d9e6
...
...
@@ -542,6 +542,8 @@ void lex_start(THD *thd)
lex
->
reset_slave_info
.
all
=
false
;
lex
->
limit_rows_examined
=
0
;
lex
->
limit_rows_examined_cnt
=
ULONGLONG_MAX
;
lex
->
var_list
.
empty
();
lex
->
stmt_var_list
.
empty
();
DBUG_VOID_RETURN
;
}
...
...
@@ -4233,6 +4235,17 @@ int LEX::print_explain(select_result_sink *output, uint8 explain_flags,
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
...
...
sql/sql_lex.h
View file @
1827d9e6
...
...
@@ -2401,6 +2401,8 @@ struct LEX: public Query_tables_list
List
<
Item
>
*
insert_list
,
field_list
,
value_list
,
update_list
;
List
<
List_item
>
many_values
;
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_param
>
param_list
;
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
,
bool
is_analyze
,
bool
*
printed_anything
);
void
restore_set_statement_var
();
};
...
...
sql/sql_parse.cc
View file @
1827d9e6
...
...
@@ -2635,6 +2635,101 @@ mysql_execute_command(THD *thd)
thd
->
get_binlog_format
(
&
orig_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
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
)
||
open_and_lock_tables
(
thd
,
all_tables
,
TRUE
,
0
)))
goto
error
;
if
(
!
(
res
=
sql_set_variables
(
thd
,
lex_var_list
)))
if
(
!
(
res
=
sql_set_variables
(
thd
,
lex_var_list
,
true
)))
{
my_ok
(
thd
);
}
...
...
@@ -4344,8 +4439,7 @@ end_with_restore_list:
DBUG_ASSERT
(
lex
->
event_parse_data
);
if
(
lex
->
table_or_sp_used
())
{
my_error
(
ER_NOT_SUPPORTED_YET
,
MYF
(
0
),
"Usage of subqueries or stored "
"function calls as part of this statement"
);
my_error
(
ER_SUBQUERIES_NOT_SUPPORTED
,
MYF
(
0
),
"CREATE/ALTER EVENT"
);
break
;
}
...
...
@@ -4665,8 +4759,7 @@ end_with_restore_list:
{
if
(
lex
->
table_or_sp_used
())
{
my_error
(
ER_NOT_SUPPORTED_YET
,
MYF
(
0
),
"Usage of subqueries or stored "
"function calls as part of this statement"
);
my_error
(
ER_SUBQUERIES_NOT_SUPPORTED
,
MYF
(
0
),
"KILL"
);
break
;
}
...
...
@@ -5059,6 +5152,7 @@ create_sp_error:
case
SQLCOM_COMPOUND
:
DBUG_ASSERT
(
all_tables
==
0
);
DBUG_ASSERT
(
thd
->
in_sub_stmt
==
0
);
lex
->
sphead
->
m_sql_mode
=
thd
->
variables
.
sql_mode
;
if
(
do_execute_sp
(
thd
,
lex
->
sphead
))
goto
error
;
break
;
...
...
@@ -5482,6 +5576,8 @@ finish:
DBUG_ASSERT
(
!
thd
->
in_active_multi_stmt_transaction
()
||
thd
->
in_multi_stmt_transaction_mode
());
lex
->
restore_set_statement_var
();
lex
->
unit
.
cleanup
();
if
(
!
thd
->
in_sub_stmt
)
...
...
sql/sql_plugin.h
View file @
1827d9e6
...
...
@@ -189,4 +189,5 @@ extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
int
type
,
uint
state_mask
,
void
*
arg
);
extern
bool
plugin_dl_foreach
(
THD
*
thd
,
const
LEX_STRING
*
dl
,
plugin_foreach_func
*
func
,
void
*
arg
);
#endif
sql/sql_prepare.cc
View file @
1827d9e6
...
...
@@ -3299,7 +3299,7 @@ void Prepared_statement::cleanup_stmt()
{
DBUG_ENTER
(
"Prepared_statement::cleanup_stmt"
);
DBUG_PRINT
(
"enter"
,(
"stmt: 0x%lx"
,
(
long
)
this
));
thd
->
restore_set_statement_var
();
cleanup_items
(
free_list
);
thd
->
cleanup_after_query
();
thd
->
rollback_item_tree_changes
();
...
...
@@ -3619,7 +3619,9 @@ Prepared_statement::execute_loop(String *expanded_query,
Reprepare_observer
reprepare_observer
;
bool
error
;
int
reprepare_attempt
=
0
;
#ifndef DBUG_OFF
Item
*
free_list_state
=
thd
->
free_list
;
#endif
thd
->
select_number
=
select_number_after_prepare
;
/* Check if we got an error when sending long data */
if
(
state
==
Query_arena
::
STMT_ERROR
)
...
...
@@ -3646,7 +3648,7 @@ reexecute:
allocated items when cleaning up after validation of the prepared
statement.
*/
DBUG_ASSERT
(
thd
->
free_list
==
NULL
);
DBUG_ASSERT
(
thd
->
free_list
==
free_list_state
);
/*
Install the metadata observer. If some metadata version is
...
...
sql/sql_yacc.yy
View file @
1827d9e6
...
...
@@ -256,7 +256,6 @@ static bool maybe_start_compound_statement(THD *thd)
Lex->sp_chistics.suid= SP_IS_NOT_SUID;
Lex->sphead->set_body_start(thd, YYLIP->get_cpp_ptr());
Lex->sphead->m_sql_mode= thd->variables.sql_mode;
}
return 0;
}
...
...
@@ -788,8 +787,10 @@ static void sp_create_assignment_lex(THD *thd, bool no_lookahead)
lex->var_list.empty();
lex->autocommit= 0;
/* get_ptr() is only correct with no lookahead. */
DBUG_ASSERT(no_lookahead);
if (no_lookahead)
lex->sphead->m_tmp_query= lip->get_ptr();
else
lex->sphead->m_tmp_query= lip->get_tok_end();
/* Inherit from outer lex. */
lex->option_type= old_lex->option_type;
}
...
...
@@ -932,10 +933,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
Currently there are 16
3
shift/reduce conflicts.
Currently there are 16
4
shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 16
3
%expect 16
4
/*
Comments for TOKENS.
...
...
@@ -1481,6 +1482,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token STARTING
%token STARTS_SYM
%token START_SYM /* SQL-2003-R */
%token STATEMENT_SYM
%token STATS_AUTO_RECALC_SYM
%token STATS_PERSISTENT_SYM
%token STATS_SAMPLE_PAGES_SYM
...
...
@@ -14321,6 +14323,7 @@ keyword_sp:
| SQL_NO_CACHE_SYM {}
| SQL_THREAD {}
| STARTS_SYM {}
| STATEMENT_SYM {}
| STATUS_SYM {}
| STORAGE_SYM {}
| STRING_SYM {}
...
...
@@ -14395,8 +14398,37 @@ set:
}
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_option_value_list:
...
...
sql/sys_vars.cc
View file @
1827d9e6
This diff is collapsed.
Click to expand it.
sql/sys_vars.h
View file @
1827d9e6
...
...
@@ -57,6 +57,7 @@
// this means that Sys_var_charptr initial value was malloc()ed
#define PREALLOCATED sys_var::ALLOCATED+
#define PARSED_EARLY sys_var::PARSE_EARLY+
#define NO_SET_STMT sys_var::NO_SET_STATEMENT+
/*
Sys_var_bit meaning is reversed, like in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment