返回首页

gbase数据、南大通用产品文档:GBase8sGCIIntervalFromText

更新日期:2024年09月11日

函数原型:
sword GCIIntervalFromText ( void *hndl,
GCIError *err,
const GCIText *inpstring,
size_t str_len,
GCIInterval *result );
功能描述:

把字符串的日期时间转换成INTERNAL。字符串分为日期字符串和时间字符串。
参数说明:
hndlp(输入)
上下文或者环境句柄

errhp(输入)


错误信息句柄,该接口调用失败时,错误信息会存在该句柄上。
inpstring(输入)
格式为”y-m”或者”d hh:mm:ss.f9”或”d hh:mm:ss”
str_len(输入)
字符串长度
result(输入/输出)
日期或时间的输出
返回值:

如果执行成功,返回GCI_SUCCESS,否则返回GCI_ERROR
注:
请参INTERVAL 数据类型阅相关手册


搭建环境样例
1.
先安装虚拟集群。
2.
创建两个VC,分别是vc1 和vc2。
3.
在vc1 和vc2 下分别创建一个distribution。
gcadmin distribution gcChangeInfo.xml p 1 d 1 vc vc1
gcadmin distribution gcChangeInfo.xml p 1 d 1 vc vc2
4.
初始化vc1 和vc2 的hashmap。

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
221
gccli -uroot -Dvc1. -e"initnodedatamap"
gccli -uroot -Dvc2. -e"initnodedatamap from vc1"

镜像功能样例
-- prepare data
drop database if exists vc1.mirror_test;
drop database if exists vc2.mirror_test;
create database vc1.mirror_test;
create database vc2.mirror_test;
create table vc1.mirror_test.t_rand
(l_orderkey bigint, l_partkey bigint, l_suppkey bigint,
l_linenumber bigint, l_quantity decimal(15,2),
l_extendedprice decimal(15,2), l_discount decimal(15,2),
l_tax decimal(15,2), l_returnflag char(1), l_linestatus char(1),
l_shipdate date, l_commitdate date, l_receiptdate date,
l_shipinstruct char(25), l_shipmode char(10), l_comment varchar(50));
create table vc1.mirror_test.t_hash
(l_orderkey bigint, l_partkey bigint, l_suppkey bigint,
l_linenumber bigint, l_quantity decimal(15,2),
l_extendedprice decimal(15,2), l_discount decimal(15,2),
l_tax decimal(15,2), l_returnflag char(1), l_linestatus char(1),
l_shipdate date, l_commitdate date, l_receiptdate date,
l_shipinstruct char(25), l_shipmode char(10), l_comment varchar(50))
distributed by ('l_orderkey');
create table vc1.mirror_test.t_rep
(l_orderkey bigint, l_partkey bigint, l_suppkey bigint,
l_linenumber bigint, l_quantity decimal(15,2),
l_extendedprice decimal(15,2), l_discount decimal(15,2),
l_tax decimal(15,2), l_returnflag char(1), l_linestatus char(1),
l_shipdate date, l_commitdate date, l_receiptdate date,
l_shipinstruct char(25), l_shipmode char(10), l_comment varchar(50))
replicated;
insert into vc1.mirror_test.t_rand values

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
222
('1','310379','15395','1','17','23619.12','0.04','0.02','N','O','1996-03-13','1996-02-12','
1996-03-22','DELIVER IN PERSON','TRUCK','blithely regular ideas caj'),
('2','212340','2361','1','38','47588.54','0.00','0.05','N','O','1997-01-28','1997-01-14','1
997-02-02','TAKE BACK RETURN','RAIL','carefully ironic platelets against t'),
('3','8594','3595','1','45','67616.55','0.06','0.00','R','F','1994-02-02','1994-01-04','199
4-02-23','NONE','AIR','blithely s'),
('4','176070','11095','1','30','34382.10','0.03','0.08','N','O','1996-01-10','1995-12-14','
1996-01-18','DELIVER IN PERSON','REG AIR','special dependencies am'),
('5','217139','17140','1','15','15841.80','0.02','0.04','R','F','1994-10-31','1994-08-31','
1994-11-20','NONE','AIR','unusual, even instructio'),
('6','279271','4285','1','37','46259.62','0.08','0.03','A','F','1992-04-27','1992-05-15','1
992-05-02','TAKE BACK RETURN','TRUCK','ruthlessly unusual warhorses sleep
slyly af'),
('7','364104','19159','1','12','14017.08','0.07','0.03','N','O','1996-05-07','1996-03-13','
1996-06-03','TAKE BACK RETURN','FOB','pending requests sleep furiously
above'),
('32','165408','15425','1','28','41255.20','0.05','0.08','N','O','1995-10-23','1995-08-27'
,'1995-10-26','TAKE BACK RETURN','TRUCK','ironic requests dazzle. final d'),
('33','122671','17690','1','31','52503.77','0.09','0.04','A','F','1993-10-29','1993-12-19'
,'1993-11-08','COLLECT COD','TRUCK','slyly even requests are f'),
('34','176723','1732','1','13','23396.36','0.00','0.07','N','O','1998-10-23','1998-09-14','
1998-11-06','NONE','REG AIR','regular deposits grow. regu');
insert into vc1.mirror_test.t_hash select * from vc1.mirror_test.t_rand;
insert into vc1.mirror_test.t_rep select * from vc1.mirror_test.t_rand;
-- test create del mirror table

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
223
alter table vc1.mirror_test.t_rand create mirror to vc2;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_rand';
select * from vc1.mirror_test.t_rand where l_orderkey not in (select l_orderkey
from vc2.mirror_test.t_rand);
alter table vc1.mirror_test.t_hash create mirror to vc2;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_hash';
select * from vc1.mirror_test.t_hash where l_orderkey not in (select l_orderkey
from vc2.mirror_test.t_hash);
alter table vc1.mirror_test.t_rep create mirror to vc2;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_rep';
select * from vc1.mirror_test.t_rep where l_orderkey not in (select l_orderkey from
vc2.mirror_test.t_rep);
alter table vc1.mirror_test.t_rand delete mirror;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_rand';
select * from vc1.mirror_test.t_rand where l_orderkey not in (select l_orderkey
from vc2.mirror_test.t_rand);
alter table vc1.mirror_test.t_hash delete mirror;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_hash';
select * from vc1.mirror_test.t_hash where l_orderkey not in (select l_orderkey
from vc2.mirror_test.t_hash);
alter table vc1.mirror_test.t_rep delete mirror;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_rep';

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
224
select * from vc1.mirror_test.t_rep where l_orderkey not in (select l_orderkey from
vc2.mirror_test.t_rep);
alter table vc2.mirror_test.t_rand create mirror to vc1 force;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_rand';
select * from vc1.mirror_test.t_rand where l_orderkey not in (select l_orderkey
from vc2.mirror_test.t_rand);
alter table vc2.mirror_test.t_hash create mirror to vc1 force;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_hash';
select * from vc1.mirror_test.t_hash where l_orderkey not in (select l_orderkey
from vc2.mirror_test.t_hash);
alter table vc2.mirror_test.t_rep create mirror to vc1 force;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
index_name='mirror_test.t_rep';
select * from vc1.mirror_test.t_rep where l_orderkey not in (select l_orderkey from
vc2.mirror_test.t_rep);
-- test create del database mirror
alter database vc1.mirror_test create mirror to vc2;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
dbname='mirror_test' order by index_name;
alter database vc1.mirror_test delete mirror;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
dbname='mirror_test' order by index_name;
alter database vc1.mirror_test create mirror to vc2 force;
select vc_id, index_name, mirror_vc_id from gbase.table_distribution where vc_id
in (select ID from
information_schema.vc where name in ('vc1', 'vc2')) and
dbname='mirror_test' order by index_name;

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
225
drop database vc1.mirror_test;
drop database vc2.mirror_test;

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
226



sword GCIThreadIdSet (
void *hndl,
GCIError *err,
GCIThreadId *tidDest,
GCIThreadId *tidSrc
);

将一个GCIThreadId 设置为另一个GCIThreadId。

参数
输入
/输出


hndl
输入/输出
GCI 环境或用户会话句柄
err
输入/输出
错误信息句柄,该接口调用失败时,错误信息会存在该句柄上
tidDest
输出
指向目标GCIThreadId 的位置
tidSrc
输入
指向源GCIThreadId 的位置

如果执行成功,返回 GCI_SUCCESS,否则返回 GCI_ERROR。

GBase 8s GCI 接口使用指南

南大通用数据技术股份有限公司 122