返回首页

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

更新日期:2024年09月11日

ifx_int8tolong() 函数将 int8 类型数值转换为 C long 类型数值。
语法
mint ifx_int8tolong(int8_val, lng_val)
ifx_int8_t *int8_val;
int4 *lng_val;
int8_val

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

指向 ifx_int8tolong() 将其值转换为 int4 整数类型值的 int8 结构的指针。
lng_val
指向 ifx_int8tolong() 放置转换的结果处的 int4 整数的指针。

返回代码
0
转换成功。
-1200
int8 类型的数值的大小大于 2,147,483,647。

示例

demo 目录中的文件 int8tolong.ec 包含下列样例程序。
/*
* ifx_int8tolong.ec *
The following program converts three strings to INT8 types and converts the INT8 type
values to C long type values.Then the values are displayed.

*/

#include

EXEC SQL include "int8.h";

char string1[] = "-1,555,345,698";
char string2[] = "3,235,635";
char string3[] = "553.24";

main()
{
int x;
long l =0;
ifx_int8_t num1, num2, num3;

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


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

if (x = ifx_int8cvasc(string1, strlen(string1), &num1))
{
printf("Error %d in converting string1 to INT8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string2, strlen(string2), &num2))
{
printf("Error %d in converting string2 to INT8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string3, strlen(string3), &num3))
{
printf("Error %d in converting string3 to INT8\n", x);
exit(1);
}
printf("\nConverting INT8 to long\n");
if (x= ifx_int8tolong(&num1, &l))
{
printf("\tError %d in converting INT8 to long\n", x);
exit(1);
}
else
{
printf("String 1= %s\n", string1);
printf("INT8 value is = %d\n", l);
}

printf("\nConverting second INT8 to long\n");
if (x= ifx_int8tolong(&num2, &l))
{

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

printf("\tError %d in converting INT8 to long\n", x);
exit(1);
}
else
{
printf("String2 = %s\n", string2);
printf("INT8 value is = %d\n",l);
}
printf("\nConverting third INT8 to long\n");

/* Note that the decimal places will be truncated. */

if (x= ifx_int8tolong(&num3, &l))
{
printf("\tError %d in converting INT8 to long\n", x);
exit(1);
}
else
{
printf("String3 = %s\n", string3);
printf("INT8 value is = %d\n",l);
}
printf("\nIFX_INT8tOLONG Sample Program over.\n\n");
exit(0);
}
输出

IFX_INT8tOLONG Sample ESQL Program running.

Converting INT8 to long

Executing: ifx_int8tolong(&num1,&l)
String 1= -1,555,345,698

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

The value of the first long is = -1555345698


Converting second INT8 to long

Executing: ifx_int8tolong(&num2, &l)
String2 = 3,235,635
The value of the second long is = 3235635


Converting third INT8 to long

Executing: ifx_int8tolong(&num3, &l)
String3 = 553.24
The value of the third long is = 553
IFX_INT8tOLONG Sample Program over.

操作场景
集群安装完成后,管理员可以通过gcadmin 查看集群的运行状态。
前提条件
gcadmin 命令在管理员用户(即安装时指定的dbaUser)下进行操作。
操作步骤
步骤1
查看集群各节点状态是否正常,显示内容如下:
$ gcadmin
CLUSTER STATE:
ACTIVE
VIRTUAL CLUSTER MODE:
NORMAL
======================================
|
GBASE GCWARE CLUSTER INFORMATION
|
======================================
| NodeName |
IpAddress
| gcware |
--------------------------------------
| gcware1
| 192.168.146.20 |
OPEN
|
--------------------------------------
| gcware2
| 192.168.146.21 |
OPEN
|
--------------------------------------
| gcware3
| 192.168.146.22 |
OPEN
|
--------------------------------------
========================================================
|
GBASE COORDINATOR CLUSTER INFORMATION
|
========================================================
|
NodeName
|
IpAddress
| gcluster | DataState |
--------------------------------------------------------
| coordinator1 | 192.168.146.20 |
OPEN
|
0
|
--------------------------------------------------------
| coordinator2 | 192.168.146.21 |
OPEN
|
0
|
--------------------------------------------------------
| coordinator3 | 192.168.146.22 |
OPEN
|
0
|
--------------------------------------------------------
===========================================================
=======
|
GBASE DATA CLUSTER INFORMATION
|
===========================================================
=======
|NodeName|IpAddress |DistributionId |gnode |syncserver | DataState |

GBase 8a MPP Cluster 产品手册
3 集群安装升级与卸载
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
73
------------------------------------------------------------------
|node1
|192.168.146.21
|
1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node2
|192.168.146.41
|
1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node3
|192.168.146.20
|
1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node4
|192.168.146.40
| 1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node5
|192.168.146.23
| 1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node6
|192.168.146.43
|
1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node7
|192.168.146.22
|
1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
|node8
|192.168.146.42 |
1
| OPEN
|
OPEN
|
0
|
------------------------------------------------------------------
步骤2
查看集群数据分片分布相关信息,显示内容如下:
$ gcadmin showdistribution
Distribution ID: 1 | State: new | Total segment num: 16
Primary Segment Node IP
Segment ID
Duplicate Segment node IP
===========================================================
=======
|


GBase 8s 管理员指南
南大通用数据技术股份有限公司
- 483 -
如果共享磁盘集群发生故障,必须对受影响的数据库空间执行复原。需要执行的复原类型
取决于是否损坏了关键数据。
关键数据已损坏
如果主服务器发生了故障,导致根数据库、包含逻辑日志文件的数据库空间或包含物理日
志的数据库空间损坏,那么必须将失败的数据库服务器视为其磁盘上没有数据。 必须对
主服务器执行完全复原。在这种情况下,主服务器和 SD 辅助服务器处于脱机状态。
要在介质出现严重故障之后恢复共享磁盘集群,请执行以下操作:
1. 对主服务器执行完全复原。根据备份是使用 ON-Bar 还是 ontape 实用程序执行
的,运行以下某个命令:

onbar -r

ontape -r
复原完成之后,主服务器将重新启动。
2. 重新启动 SD 辅助服务器。
此外,也可以对主服务器上的关键数据库空间执行冷复原,重新启动 SD 辅助服务器,然
后对非关键数据库空间执行热复原。
关键数据未损坏
如果不包含关键介质的磁盘出现故障,可以使用热复原来复原受影响的数据库空间。在这
种情况下,主服务器和 SD 辅助服务器处于联机状态。
要恢复共享磁盘集群中的非关键数据,请执行以下操作:
1. 关闭并重新启动 SD 辅助服务器。
2. 对受影响的数据库空间执行热复原。根据备份是使用 ON-Bar 还是 ontape 实用程
序执行的,运行以下某个命令:

onbar -r 加上要复原的数据库空间的名称

ontape -r -D 加上要复原的数据库空间的名称