diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-05-21 15:33:35 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-05-21 16:10:03 +0200 |
commit | 1921df669712135b2b6f78c96c2aa6ae9a7399f2 (patch) | |
tree | f906e638ba2d984ad1d5f827fe1bdb50e4f17d8e | |
parent | fceffcdf0b5c3531f32d5dce3909889d5bf2909f (diff) | |
download | mariadb-git-bb-10.4-MDEV-19540.tar.gz |
MDEV-19540: 10.4 allow lock options with SELECT in brackets which previous version do notbb-10.4-MDEV-19540
Check locking options and brackets combinations.
-rw-r--r-- | mysql-test/main/parser.result | 15 | ||||
-rw-r--r-- | mysql-test/main/parser.test | 16 | ||||
-rw-r--r-- | sql/sql_lex.cc | 8 |
3 files changed, 38 insertions, 1 deletions
diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 34c119a322e..2e2342161fc 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1770,3 +1770,18 @@ ERROR HY000: Unknown system variable 'password' SELECT @@GLOBAL.role; ERROR HY000: Unknown system variable 'role' 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 diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 3a7c4f6467e..35a2334eec2 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1537,3 +1537,19 @@ SELECT @@GLOBAL.password; SELECT @@GLOBAL.role; --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 diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 67bc8b31a98..9550350cc44 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -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, 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))) return NULL; @@ -9519,7 +9525,7 @@ bool SELECT_LEX_UNIT::set_lock_to_the_last_select(Lex_select_lock l) if (sel->braces) { my_error(ER_WRONG_USAGE, MYF(0), "lock options", - "End SELECT expression"); + "SELECT in brackets"); return TRUE; } l.set_to(sel); |