当前位置:网站首页>Built in function lock correlation
Built in function lock correlation
2022-07-27 20:12:00 【Hua Weiyun】
11.9 Locking and unlocking function
MySQL Functions for locking and unlocking data are provided in , These functions include GET_LOCK(value,timeout)、RELEASE_LOCK(value)、IS_FREE_LOCK(value) and IS_USED_LOCK(value) function .
11.9.1 GET_LOCK(value,timeout) function
GET_LOCK(value,timeout) The function uses a string value Get lock with given name , continued timeout second . If the lock is acquired successfully , Then return to 1, If lock acquisition timeout , Then return to 0, If an error occurs , Then return to NULL. Use GET_LOCK(value,timeout) Lock obtained by function , When executed RELEASE_LOCK(value) Or disconnect the database ( Including normal disconnection and abnormal disconnection ), The lock will be released . An example is as follows :
mysql> SELECT GET_LOCK('mysql',1000);+------------------------+| GET_LOCK('mysql',1000) |+------------------------+| 1 |+------------------------+1 row in set (0.00 sec)Get a name of mysql, Duration is 1000s Lock of .
11.9.2 RELEASE_LOCK(value) function
RELEASE_LOCK(value) The function will take value Named lock release . If the cancellation is successful , Then return to 1, If the thread has not created a lock , Then return to 0, If the value The named lock does not exist , Then return to NULL.
mysql> SELECT RELEASE_LOCK('mysql');+-----------------------+| RELEASE_LOCK('mysql') |+-----------------------+| 1 |+-----------------------+1 row in set (0.10 sec)Be careful : There are two cases when a lock does not exist .
· Never been GET_LOCK(value,timeout) Function obtained .
· The lock has been invoked RELEASE_LOCK(value) Function released .
11.9.3 IS_FREE_LOCK(value) function
IS_FREE_LOCK(value) The function judges with value Whether the named lock can be used . If it can be used , Then return to 1, If you can't use , That is to say, it is being used , Then return to 0, If an error occurs , Then return to NULL. An example is as follows :
mysql> SELECT IS_FREE_LOCK('mysql');+-----------------------+| IS_FREE_LOCK('mysql') |+-----------------------+| 1 |+-----------------------+1 row in set (0.00 sec)11.9.4 IS_USED_LOCK(value) function
IS_USED_LOCK(value) The function judges with value Whether the named lock is being used , If it is being used , Then return the database connection using the lock ID, Otherwise return to NULL. An example is as follows :
mysql> SELECT IS_USED_LOCK('mysql'), IS_USED_LOCK('test');+-----------------------+----------------------+| IS_USED_LOCK('mysql') | IS_USED_LOCK('test') |+-----------------------+----------------------+| NULL | 8 |+-----------------------+----------------------+1 row in set (0.00 sec)边栏推荐
- 1.2 pedestrian recognition based on incremental generation of occlusion and confrontation suppression (code understanding and experimental progress + Report)
- 【OpenBMC 系列】4.启动流程 使用qume模拟ast2600-evb
- System information function of MySQL function summary
- LeetCode练习2——两数之和
- In 2019, the global semiconductor revenue fell by 12% year-on-year, and China's market share ranked first
- Kubectl's access to pod logs -- the way to build a dream
- C# 后台GC 的前因后果
- C语言pow函数(c语言中指数函数怎么打)
- 2022年,软件测试还能学吗?别学了,软件测试岗位饱和了...
- Use cpolar to build a business website (5)
猜你喜欢

Explore a new generation of activities to win customers, virtualization activities win a trick | manufacturer solicitation

codeforces每日5题(均1500)-第二十四天

新库上线 | CnOpenData中国全部专利详细地址数据

China business CDP white paper | love Analysis Report

一看就懂的ESLint
![22 year PMP test [Quanzhen agile test]](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
22 year PMP test [Quanzhen agile test]

C# 后台GC 的前因后果

An in-depth understanding of crystal oscillation circuit derived from xtalin pin and xtalout pin of single chip microcomputer

产品经理:排查下线上哪里冒出个“系统异常”的错误提示

Qt的QTextToSpeech类实现语音播报功能
随机推荐
transformers-bert
How to encrypt the data in MySQL database? Mysql8.0 comes with new features
剑指 Offer 25. 合并两个排序的链表
Acwing 692. g bus count difference + prefix and
总线Bus是什么意思
Membership card head assembly usage document
西数移动硬盘无法读取(高枕无忧的成语)
Product Manager: check where there is an error prompt of "system exception" on the offline
Underlying principle of mvcc
第3章 基本操作
由单片机XTALIN引脚和XTALOUT引脚导出的对晶体震荡电路的深入理解
LED高精度体重秤方案规格书
TS2532: Object is possibly ‘undefined‘
C#求完全数,输出水仙花以及类的使用
Understanding of basic concepts of channel capacity and channel bandwidth
Cfssl of pki/tls tool -- the road to dream
unity2D 动态漫画剧本(给猛虎桥章节做动画演示二)
《安富莱嵌入式周报》第275期:2022.07.18--2022.07.24
邬贺铨:因地制宜 数字化技术赋能“双碳”实践
[pytorch series] detailed explanation of the torchvision image processing library of pytorch