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:
Sergey Vojtovich 2015-07-23 12:50:58 +04:00
commit 392df76bc3
6 changed files with 40 additions and 4 deletions

View file

@ -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);