mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-4017 - GET_LOCK() with negative timeouts has strange behavior
GET_LOCK() silently accepted negative values and NULL for timeout. Fixed GET_LOCK() to issue a warning and return NULL in such cases.
This commit is contained in:
@@ -228,7 +228,7 @@ rollback;
|
||||
create table t0 (n int);
|
||||
insert t0 select * from t1;
|
||||
set autocommit=1;
|
||||
insert into t0 select GET_LOCK("lock1",null);
|
||||
insert into t0 select GET_LOCK("lock1",0);
|
||||
set autocommit=0;
|
||||
create table t2 (n int) engine=innodb;
|
||||
insert into t2 values (3);
|
||||
|
@@ -361,5 +361,18 @@ set optimizer_switch=@optimizer_switch_save;
|
||||
drop view v_merge, vm;
|
||||
drop table t1,tv;
|
||||
#
|
||||
# MDEV-4017 - GET_LOCK() with negative timeouts has strange behavior
|
||||
#
|
||||
SELECT GET_LOCK('ul1', NULL);
|
||||
GET_LOCK('ul1', NULL)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1411 Incorrect timeout value: 'NULL' for function get_lock
|
||||
SELECT GET_LOCK('ul1', -1);
|
||||
GET_LOCK('ul1', -1)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1411 Incorrect timeout value: '-1' for function get_lock
|
||||
#
|
||||
# End of 5.5 tests
|
||||
#
|
||||
|
@@ -258,7 +258,7 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
||||
create table t0 (n int);
|
||||
insert t0 select * from t1;
|
||||
set autocommit=1;
|
||||
insert into t0 select GET_LOCK("lock1",null);
|
||||
insert into t0 select GET_LOCK("lock1",0);
|
||||
set autocommit=0;
|
||||
create table t2 (n int) engine=innodb;
|
||||
insert into t2 values (3);
|
||||
|
@@ -242,7 +242,7 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
||||
create table t0 (n int);
|
||||
insert t0 select * from t1;
|
||||
set autocommit=1;
|
||||
insert into t0 select GET_LOCK("lock1",null);
|
||||
insert into t0 select GET_LOCK("lock1",0);
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
|
||||
set autocommit=0;
|
||||
@@ -288,7 +288,7 @@ master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `test`; insert t0 select * from t1
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `test`; insert into t0 select GET_LOCK("lock1",null)
|
||||
master-bin.000001 # Query # # use `test`; insert into t0 select GET_LOCK("lock1",0)
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; create table t2 (n int) engine=innodb
|
||||
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t1`,`ti`
|
||||
|
@@ -391,6 +391,11 @@ set optimizer_switch=@optimizer_switch_save;
|
||||
drop view v_merge, vm;
|
||||
drop table t1,tv;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-4017 - GET_LOCK() with negative timeouts has strange behavior
|
||||
--echo #
|
||||
SELECT GET_LOCK('ul1', NULL);
|
||||
SELECT GET_LOCK('ul1', -1);
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.5 tests
|
||||
|
@@ -4184,7 +4184,25 @@ longlong Item_func_get_lock::val_int()
|
||||
it's not guaranteed to be same as on master.
|
||||
*/
|
||||
if (thd->slave_thread)
|
||||
{
|
||||
null_value= 0;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
if (args[1]->null_value ||
|
||||
(!args[1]->unsigned_flag && ((longlong) timeout < 0)))
|
||||
{
|
||||
char buf[22];
|
||||
if (args[1]->null_value)
|
||||
strmov(buf, "NULL");
|
||||
else
|
||||
llstr(((longlong) timeout), buf);
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
|
||||
"timeout", buf, "get_lock");
|
||||
null_value= 1;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
mysql_mutex_lock(&LOCK_user_locks);
|
||||
|
||||
|
Reference in New Issue
Block a user