返回首页

gbase数据、南大通用产品文档:GBase8cMOT 持久性概念

更新日期:2024年09月11日

持久性是指长期的数据保护(也称为磁盘持久性)
。持久性意味着存储的数据不会遭受
任何形式的退化或破坏,
因此数据不会丢失或损坏。
持久性可确保在有计划停机
(例如维护)
或计划外崩溃(例如电源故障)后数据和MOT 引擎恢复到一致状态。
内存存储是易失的,
需要电源来维护所存储的信息。
另一方面,
磁盘存储是非易失性的,
这意味着它不需要电源来维护存储的信息,因此它不用担心停电。MOT 使用这两种类型的
存储,
它拥有内存中的所有数据,
同时将事务性更改持久化到磁盘,
并保持频繁的定期MOT
检查点,以确保在关机时恢复数据。
用户必须保证有足够的磁盘空间用于日志记录和检查点操作。
检查点使用单独的驱动器,
通过减少磁盘I/O 负载来提高性能。

GBase 8c V5 开发者手册
南大通用数据技术股份有限公司
493
有关如何在MOT 引擎中实现持久性的概述,请参见MOT 关键技术。
MOT 的WAL 重做日志和检查点启用了持久性,如下所述。

要配置 GBase 8s JDBC Driver 的数据库连接,来使用“安全套接层”(SSL)协议,需要
将 sslConnection 属性设置为 TRUE。
在至数据源的连接可使用 SSL 协议之前,
必须在数据库服务器中将应用程序连接至的端口
配置为 SSL 监听器端口。
请在 Connection 或 DataSource 实例上设置 sslConnection 属性。下列示例演示如何在
Connection 实例上设置 sslConnection 属性:
java.util.Properties properties = new java.util.Properties();
properties.put("user", "xxxx");
properties.put("password", "yyyy");
properties.put("sslConnection", "true");

GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 58 -
java.sql.Connection con =
java.sql.DriverManager.getConnection(url, properties);

intofmtasc() 函数使用格式化掩码来将 interval 变量转换为字符串。

语法
mint intofmtasc(invvalue, outbuf, buflen, fmtstring)
intrvl_t *invvalue;
char *outbuf;
mint buflen;

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 833 -

char *fmtstring;
invvalue
指向要转换的初始化了的 interval 变量的指针。
outbuf
指向为 invvalue 中的值接收字符串的缓冲区的指针。
buflen
outbuf 缓冲区的长度。
fmtstring
指向包含用于 outbuf 字符串的格式化掩码的缓冲区的指针。此时间格式化掩码包含
与 DBTIME 环境变量支持的相同的格式化伪指令。

用法
您必须以您想要该字符串拥有的限定符来初始化 invvalue 中的 interval 变量。如果
您未初始化 interval 变量,
则该函数返回不可预料的值。
outbuf 中的字符串不包括 SQL 语
句用来定界 INTERVAL 文字的限定符或圆括号。

格式化掩码 fmtstring 不需要暗示与 interval 变量相同的限定符。当暗示的格式化掩
码限定符不同于 interval 限定符时,
在必要时,
intofmtasc() 将该结果转换为恰当的单位
(如
同它调用了 invextend() 函数那样)

然而,
两个限定符必须同时属于同一类:
或者 year to
month 类,或者 day to fraction 类。

如果 fmtstring 为空字符串,则 intofmtasc() 函数将 outbuf 设置为空字符串。
DBTIME 环境变量接受的格式化伪指令 %B、%b 和 %p 不适用于 fmtstring,因为
month name 和 a.m./p.m. 信息与时间的间隔无关。如果 interval 大于 99 年,则请使
用 %Y 伪指令(%y 仅可处理两位数)。对于小时,请使用 %H(而不是 %I,因为 %I
仅可表示 12 小时)。如果 fmtstring 为空字符串,则该函数返回错误。

如果该字符串和格式化掩码是可接受的,则 intofmtasc() 函数设置 invvalue 中的
interval 值,
并返回零。
否则,
该函数返回错误代码,
且 interval 变量包含不可预料的值。
返回代码
0
转换成功。
<0
转换失败。

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 834 -


示例

demo 目录在文件 intofmtasc.ec 中包含此样例程序。
/*
*intofmtasc.ec*
The following program illustrates the conversion of interval values to ASCII strings with
the specified formats.
*/

#include

EXEC SQL include datetime;

main()
{
char out_str[60];
char out_str2[60];
char out_str3[60];
mint x;

EXEC SQL BEGIN DECLARE SECTION;
interval day to minute short_time;
interval minute(5) to second moment;
EXEC SQL END DECLARE SECTION;

printf("INTOFMTASC Sample ESQL Program running.\n\n");

* Initialize short_time (day to minute) interval value */
printf("Interval string #1 = '20 days, 3 hours, 40 minutes'\n");
x = incvfmtasc("20 days, 3 hours, 40 minutes",
"%d days, %H hours, %M minutes", &short_time);
/*Turn the interval into ascii string of a certain format. */

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 835 -

x = intofmtasc(&short_time, out_str, sizeof(out_str),
"%d days, %H hours, %M minutes to go!");
printf("\tFormatted value: %s\n", out_str);

/* Initialize moment (minute(5) to second interval value */
printf("\nInterval string #2: '428 minutes, 30 seconds'\n");
x = incvfmtasc("428 minutes, 30 seconds",
"%M minutes, %S seconds", &moment);

/* Turn each interval into ascii string of a certain format. Note
* that the second and third calls to intofmtasc both use moment
* as the input variable, but the output strings have different formats.
*/
x = intofmtasc(&moment, out_str2, sizeof(out_str2),
"%M minutes and %S seconds left.");
x = intofmtasc(&moment, out_str3, sizeof(out_str3),
"%H hours, %M minutes, and %S seconds still left.");

/* Print each resulting string */
printf("\tFormatted value: %s\n", out_str2);
printf("\tFormatted value: %s\n", out_str3);

printf("\nINTOFMTASC Sample Program over.\n\n");
}
输出
INTOFMTASC Sample ESQL Program running.

Interval string #1: '20 days, 3 hours, 40 minutes'
Formatted value: 20 days, 03 hours, 40 minutes to go!

Interval string #2: '428 minutes, 30 seconds'
Formatted value: 428 minutes and 30 seconds left.
Formatted value: 07 hours, 08 minutes, and 30 seconds still left.

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 836 -