Commit 1921df66 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-19540: 10.4 allow lock options with SELECT in brackets which previous version do not

Check locking options and brackets combinations.
parent fceffcdf
...@@ -1770,3 +1770,18 @@ ERROR HY000: Unknown system variable 'password' ...@@ -1770,3 +1770,18 @@ ERROR HY000: Unknown system variable 'password'
SELECT @@GLOBAL.role; SELECT @@GLOBAL.role;
ERROR HY000: Unknown system variable 'role' ERROR HY000: Unknown system variable 'role'
End of 10.3 tests End of 10.3 tests
#
# MDEV-19540: 10.4 allow lock options with SELECT in brackets
# which previous version do not
#
create table t1 (a int);
(select * from t1) for update;
ERROR HY000: Incorrect usage of lock options and SELECT in brackets
(select * from t1) union (select * from t1) for update;
ERROR HY000: Incorrect usage of lock options and SELECT in brackets
(select * from t1 for update);
a
select * from t1 for update;
a
drop table t1;
# End of 10.4 tests
...@@ -1537,3 +1537,19 @@ SELECT @@GLOBAL.password; ...@@ -1537,3 +1537,19 @@ SELECT @@GLOBAL.password;
SELECT @@GLOBAL.role; SELECT @@GLOBAL.role;
--echo End of 10.3 tests --echo End of 10.3 tests
--echo #
--echo # MDEV-19540: 10.4 allow lock options with SELECT in brackets
--echo # which previous version do not
--echo #
create table t1 (a int);
--error ER_WRONG_USAGE
(select * from t1) for update;
--error ER_WRONG_USAGE
(select * from t1) union (select * from t1) for update;
(select * from t1 for update);
select * from t1 for update;
drop table t1;
--echo # End of 10.4 tests
...@@ -9246,6 +9246,12 @@ SELECT_LEX_UNIT *LEX::parsed_select_expr_cont(SELECT_LEX_UNIT *unit, ...@@ -9246,6 +9246,12 @@ SELECT_LEX_UNIT *LEX::parsed_select_expr_cont(SELECT_LEX_UNIT *unit,
SELECT_LEX_UNIT *LEX::parsed_body_select(SELECT_LEX *sel, SELECT_LEX_UNIT *LEX::parsed_body_select(SELECT_LEX *sel,
Lex_order_limit_lock * l) Lex_order_limit_lock * l)
{ {
if (sel->braces && l && l->lock.defined_lock)
{
my_error(ER_WRONG_USAGE, MYF(0), "lock options",
"SELECT in brackets");
return NULL;
}
if (!(sel= parsed_select(sel, l))) if (!(sel= parsed_select(sel, l)))
return NULL; return NULL;
...@@ -9519,7 +9525,7 @@ bool SELECT_LEX_UNIT::set_lock_to_the_last_select(Lex_select_lock l) ...@@ -9519,7 +9525,7 @@ bool SELECT_LEX_UNIT::set_lock_to_the_last_select(Lex_select_lock l)
if (sel->braces) if (sel->braces)
{ {
my_error(ER_WRONG_USAGE, MYF(0), "lock options", my_error(ER_WRONG_USAGE, MYF(0), "lock options",
"End SELECT expression"); "SELECT in brackets");
return TRUE; return TRUE;
} }
l.set_to(sel); l.set_to(sel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment