gpt4 book ai didi

mysql - 在 MariaDB 中设置无限超时 GET_LOCK()

转载 作者:行者123 更新时间:2023-11-29 10:18:11 24 4
gpt4 key购买 nike

MySQL 中的 GET_LOCK() 接受负超时值,并解释为无限超时。

MySQL 文档: GET_LOCK()

Tries to obtain a lock with a name given by the string str, using a timeout of timeout seconds. A negative timeout value means infinite timeout. The lock is exclusive. While held by one session, other sessions cannot obtain a lock of the same name.

但是在 MariaDB 中我找不到复制无限超时的方法,因为文档中没有指定任何内容。

MariaDB 文档: GET_LOCK()

GET_LOCK(str,timeout) [...] str is case insensitive for GET_LOCK() and related functions. If str is an empty string or NULL, GET_LOCK() returns NULL and does nothing. timeout is rounded to the closest integer.

我可以在 MariaDB 中复制具有 MySQL 无限超时的 GET_LOCK() 吗?

最佳答案

MariaDB 不接受 GET_LOCK 的负值:

MariaDB [test]> do get_lock('test', -1);
Query OK, 0 rows affected, 1 warning (0.00 sec)

MariaDB [test]> show warnings;
+---------+------+-----------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------+
| Warning | 1411 | Incorrect timeout value: '-1' for function get_lock |
+---------+------+-----------------------------------------------------+
1 row in set (0.00 sec)

您可以使用 0xffffffff 来模拟 MariaDB 中的相同行为:

MariaDB [test]> do get_lock('test', 0xffffff);
Query OK, 0 rows affected (1.85 sec)

关于mysql - 在 MariaDB 中设置无限超时 GET_LOCK(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49792089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com