summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-07-23 12:50:58 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-07-29 15:59:56 +0400
commit392df76bc3a40a5dd1956b12628dd6489a37be36 (patch)
treecb3420c2444e778d98330477151ac31300fd9a61 /sql/item_func.cc
parente40bc659335f7f8b69427ed2d215c34c045a5ed7 (diff)
downloadmariadb-git-392df76bc3a40a5dd1956b12628dd6489a37be36.tar.gz
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.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ed08555133f..2f5130886e6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -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);