Skip to content

Commit 844ddb1

Browse files
author
Jan Lindström
committed
MDEV-30473 : Do not allow GET_LOCK() / RELEASE_LOCK() in cluster
If WSREP_ON=ON do not allow GET_LOCK and RELEASE_LOCK functions. Instead print clear error message.
1 parent 765291d commit 844ddb1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
connection node_2;
2+
connection node_1;
3+
CREATE TABLE t (c DOUBLE,c2 INT,PRIMARY KEY(c)) ENGINE=InnoDB;
4+
INSERT INTO t values (1,1);
5+
SELECT GET_LOCK('a',1);
6+
ERROR 42000: This version of MariaDB doesn't yet support 'GET_LOCK in cluster (WSREP_ON=ON)'
7+
SHOW WARNINGS;
8+
Level Code Message
9+
Error 1235 This version of MariaDB doesn't yet support 'GET_LOCK in cluster (WSREP_ON=ON)'
10+
SELECT * FROM t;
11+
c c2
12+
1 1
13+
SELECT RELEASE_LOCK('a');
14+
ERROR 42000: This version of MariaDB doesn't yet support 'RELEASE_LOCK in cluster (WSREP_ON=ON)'
15+
SHOW WARNINGS;
16+
Level Code Message
17+
Error 1235 This version of MariaDB doesn't yet support 'RELEASE_LOCK in cluster (WSREP_ON=ON)'
18+
COMMIT;
19+
DROP TABLE t;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--source include/galera_cluster.inc
2+
3+
CREATE TABLE t (c DOUBLE,c2 INT,PRIMARY KEY(c)) ENGINE=InnoDB;
4+
INSERT INTO t values (1,1);
5+
--error ER_NOT_SUPPORTED_YET
6+
SELECT GET_LOCK('a',1);
7+
SHOW WARNINGS;
8+
SELECT * FROM t;
9+
--error ER_NOT_SUPPORTED_YET
10+
SELECT RELEASE_LOCK('a');
11+
SHOW WARNINGS;
12+
COMMIT;
13+
DROP TABLE t;
14+

sql/item_create.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4933,6 +4933,13 @@ Create_func_get_lock Create_func_get_lock::s_singleton;
49334933
Item*
49344934
Create_func_get_lock::create_2_arg(THD *thd, Item *arg1, Item *arg2)
49354935
{
4936+
#ifdef WITH_WSREP
4937+
if (WSREP_ON && WSREP(thd))
4938+
{
4939+
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GET_LOCK in cluster (WSREP_ON=ON)");
4940+
return NULL;
4941+
}
4942+
#endif /* WITH_WSREP */
49364943
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
49374944
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
49384945
return new (thd->mem_root) Item_func_get_lock(thd, arg1, arg2);
@@ -6535,6 +6542,13 @@ Create_func_release_lock Create_func_release_lock::s_singleton;
65356542
Item*
65366543
Create_func_release_lock::create_1_arg(THD *thd, Item *arg1)
65376544
{
6545+
#ifdef WITH_WSREP
6546+
if (WSREP_ON && WSREP(thd))
6547+
{
6548+
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RELEASE_LOCK in cluster (WSREP_ON=ON)");
6549+
return NULL;
6550+
}
6551+
#endif /* WITH_WSREP */
65386552
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
65396553
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
65406554
return new (thd->mem_root) Item_func_release_lock(thd, arg1);

0 commit comments

Comments
 (0)