当前位置:网站首页>GBase8s数据库使当前的连接成为休眠的连接
GBase8s数据库使当前的连接成为休眠的连接
2022-07-22 07:55:00 【爱吃萝卜冰冰凉】
在 SET CONNECTION connection DORMANT 语句中,connection 必须表示当前的连接。带有
DORMANT 选项的 SET CONNECTION 语句使指定的当前连接成为休眠的连接。
例如,下列 SET CONNECTION 语句使连接 con1 休眠:
SET CONNECTION ‘con1’ DORMANT;
如果您指定一个已经是休眠的连接,则带有 DORMANT 选项的 SET CONNECTION 语句生成错
误。例如,如果连接 con1 是当前的,而连接 con2 是休眠的,则下列 SET CONNECTION 语句
返回错误消息:
SET CONNECTION ‘con2’ DORMANT;
下列 SET CONNECTION 语句成功地执行:
SET CONNECTION ‘con1’ DORMANT;
单线程环境中的休眠连接
在单线程 GBase 8s ESQL/C 应用(不使用线程的)中,DORMANT 选项使当前的连接成为休眠
的。使用此选项使单线程的 GBase 8s ESQL/C 应用与线程安全的 GBase 8s ESQL/C 应用向上兼
容。然而,在程序执行时,单线程的环境可仅有一个活动的连接。
在线程安全环境中的休眠连接
在线程安全的 GBase 8s ESQL/C 应用中,DORMANT 选项使活动的连接成为休眠的。现在另一线
程可通过发出不带 DORMANT 选项的 SET CONNECTION 语句来使用该连接。在一个 GBase 8s
ESQL/C 应用中,线程安全的环境可有许多线程(执行特别任务的工作的并发部分),且每一线程
可有一个活动的连接。
活动的连接与特定的线程相关联。两个线程不可分享相同的活动的连接。一旦线程使活动的连接成
为休眠的,其他线程就可使用那个连接。仍然建立休眠的连接,但当前休眠的连接不与任何线程相
关联。例如,如果在名为 thread_1 的线程中名为 con1 的连接是活动的,则名为 thread_2
的线程不可使连接 con1 成为它的活动连接,直到 thread_1 已使连接 con1 成为了休眠的为
止。
下列来自线程安全的 GBase 8s ESQL/C 程序的代码片段展示在线程安全的应用之内,特定的线程
是如何使连接成为活动的,通过此连接在表上执行工作,然后再使该连接成为休眠的,以便其他线
程可使用该连接:
thread_2()
{ /* 使 con2 成为活动的连接 */
EXEC SQL connect to ‘db2’ as ‘con2’;
/Do insert on table t2 in db2/
EXEC SQL insert into table t2 values(10);
/* 使其他线程可使用 con2 */
EXEC SQL set connection ‘con2’ dormant;
}
如果使用 CONNECT . . . WITH CONCURRENT TRANSACTION 语句初始化了到数据库环境的连
接,则随后连接到那个数据库环境的任何线程都可使用正在进行的事务。此外,如果开放的游标与
这样的连接相关联,则当使该链接成为休眠的时,该游标保持打开。
在线程安全的 GBase 8s ESQL/C 应用之内的线程可通过使相关联的连接成为当前的来使用同一游
标,即使在任何给定的时间仅一个线程可使用该连接。
边栏推荐
- 力扣练习——27 翻转矩阵后的得分
- Nightmare of concurrent programs -- data competition
- [harmony OS] [ark UI] [demo] loading animation
- Bigder:40/100 how to organize a use case review
- Using dichotomy to find the elements of an array
- 力扣练习——21 有序矩阵中的第 k 个最小数组和
- How Allegro imports pictures such as high-definition logo, QR code, anti-static logo and Chinese characters
- 从0开始教你编写Makefile文件
- PostgreSQL database is deployed on Linux server. Ms level is queried locally. Pgadmin installed on windows is used to query super slow for about 20s. Is it a network problem or a database configuratio
- Rk3399 platform development series explanation (memory chapter) 15.33. Why does the available memory far exceed the physical memory?
猜你喜欢
【HMS core】【Health Kit】【FAQ】数据订阅功能问题合集
Abnormal understanding and learning
Bigder:37/100 一个误操作
数据高效治理如何开展,指标管理与数据溯源来帮忙!
Conference OA project introduction & Conference release
(11) 51 Single Chip Microcomputer -- realize the storage of stopwatch data with AT24C02 (attached with achievement display)
日期类的理解学习
使用 Abp.Zero 搭建第三方登录模块(四):微信小程序开发
JS String charAt substring() substr slice toUpperCase toLowerCase indexOf
Rk3399 platform development series explanation (memory chapter) 15.33. Why does the available memory far exceed the physical memory?
随机推荐
Using dichotomy to find the elements of an array
基础SQL Server 操作问题——仅当使用了列表并且IDENTITY_INSERT为ON时,才能为表中的标识列制定显示值
[database] addition, deletion, modification and query of MySQL table (Advanced)
Deep learning (II) takes you to understand neural networks and activation functions
UART communication experiment (query mode)
Pytoch implements word2vec
Bigder:38/100 a misoperation problem has been solved
-bash-4.2$
【论文汇总】2D目标检测文章汇总,持续更新
牛客刷SQL
Understanding and learning of arrays class
How is VR panorama displayed in all walks of life? How to implement the application?
go 切片,集合简单讲解
使用 Abp.Zero 搭建第三方登录模块(三):网页端开发
[database] addition, deletion, modification and query of MySQL table (basic)
QWidget添加右键菜单
Fibonacci series of Niuke network
【HMS core】【push kit】关于消息分类问题的集合
Replace spaces in niuke.com
【HMS core】【FAQ】【Account Kit】典型问题合集1