返回首页

gbase数据、南大通用产品文档:GBase8sbycmpr() 函数

更新日期:2024年09月11日

bycmpr() 函数比较两组给定长度的相邻字节。它返回比较的结果作为它的值。
语法
mint bycmpr(byte1, byte2, length)
char *byte1;
char *byte2;
mint length;
byte1
指向第一组相邻字节起始位置的指针。

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

byte2
指向第二组相邻字节起始位置的指针。
length
您想要 bycmpr() 比较的字节数。

用法
bycmpr() 执行对两组相邻字节的逐字节比较,直到它发现不同为止,或直到它比较字
节的 length 数目为止。bycmpr() 函数返回整数,其值(0、-1 或 +1)指示两组字节之间
比较的结果。

bycmpr() 函数从 byte1 组的字节减去 byte2 组的字节来完成比较。

返回代码
0
两个组相同。
-1
byte1 组小于 byte2 组。
+1
byte1 组大于 byte2 组。
示例
此样例程序位于 demo 目录中的 bycmpr.ec 文件中。
/*
* bycmpr.ec *

The following program performs three different byte comparisons with bycmpr() and
displays the results.
*/

#include

main()
{
mint x;

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


static char string1[] = "abcdef";
static char string2[] = "abcdeg";

static mint number1 = 12345;
static mint number2 = 12367;

static char string3[] = {0x00, 0x07, 0x45, 0x32, 0x00};
static char string4[] = {0x00, 0x07, 0x45, 0x31, 0x00};

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

/* strings */
printf("Comparing strings: String 1=%s\tString 2=%s\n", string1, string2);
printf(" Executing: bycmpr(string1, string2, sizeof(string1))\n");
x = bycmpr(string1, string2, sizeof(string1));
printf(" Result = %d\n", x);

/* ints */
printf("Comparing numbers: Number 1=%d\tNumber 2=%d\n", number1, number2);
printf(" Executing: bycmpr( (char *) &number1, (char *) &number2, ");
printf("sizeof(number1))\n");
x = bycmpr( (char *) &number1, (char *) &number2, sizeof(number1));
printf(" Result = %d\n", x);

/* non printable */
printf("Comparing strings with non-printable characters:\n");
printf(" Octal string 1=%o\tOctal string 2=%o\n", string3, string4);
printf(" Executing: bycmpr(string3, string4, sizeof(string3))\n");
x = bycmpr(string3, string4, sizeof(string3));
printf(" Result = %d\n", x);

/* bytes */

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

printf("Comparing bytes: Byte string 1=%c%c\tByte string 2=%c%c\n");
printf(" Executing: bycmpr(&string1[2], &string2[2], 2)\n");
x = bycmpr(&string1[2], &string2[2], 2);
printf(" Result = %d\n", x);

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

Comparing strings: String1=abcdef String 2=abcdeg
Executing: bycmpr(string1, string2, sizeof(string1))
Result = -1
Comparing numbers: Number 1=12345 Number 2=12367
Executing: bycmpr( (char *) &number1, (char *) &number2, sizeof(number1)
Result = -1
Comparing strings with non-printable characters:
Octal string 1=40300 Octal string 2=40310
Executing: bycmpr(string3, string4, sizeof(string3))
Result = 1
Comparing bytes: Byte string 1=cd Byte string 2=cd
Executing: bycmpr(&string1[2], &string2[2], 2)
Result = 0

BYCMPR Sample ESQL Program over.

功能描述
检查点(CHECKPOINT)是一个事务日志中的点,所有数据文件都在该点被更新以反
映日志中的信息,所有数据文件都将被刷新到磁盘。
设置事务日志检查点。预写式日志(WAL)缺省时在事务日志中每隔一段时间放置一
个检查点。可以使用gs_guc 命令设置相关运行时参数(checkpoint_segments、
checkpoint_timeout 和incremental_checkpoint_timeout)来调整这个原子化检查点的间隔。
注意事项

GBase 8c SQL 参考手册
南大通用数据技术股份有限公司
809

只有系统管理员和运维管理员可以调用CHECKPOINT。

CHECKPOINT 强制立即进行检查,而不是等到下一次调度时的检查点。
语法格式
CHECKPOINT;
参数说明

示例
--设置检查点。
gbase=#CHECKPOINT;

参数说明:
设置数据库只读模式的磁盘占用阈值,
当数据目录所在磁盘占用超过这个阈

GBase 8c V5 开发者手册
南大通用数据技术股份有限公司
1398
值,自动将数据库设置为只读模式。
取值范围:整型,1 ~ 99,表示百分比。参数修改请参考表GUC 参数设置方式进行设
置。
默认值:85