返回首页

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

更新日期:2024年09月11日

Type name is required for this data type
此数据类型是不透明类型、distinct 类型或复杂类型,它需要一个名称。

GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 319
-
使用 IN 参数的设置方法,并为以类型名称作为参数的 OUT 参数注册方法。

在GBase 8a MPP Cluster 中,使用PL/Python 存储过程语言来支持使用python 语
言编写的UDF 函数。PL/Python 以‘非信任’语言( ’untrusted’ language)的形式存

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
1405
在,这意味着它不限制用户如何使用Python。所以这种语言被命名为plpythonu。
如果Python 将来提供了新的安全机制,
会提供plpython 语言。
未信任的PL/Python
的编写者必须谨慎编写这些函数,不要用来做非法操作,因为这个功能使得拥有
DBA 身份的用户可以执行任意脚本。只有超级用户才有权限创建这些函数。

为便于理解以上概念,下表举例说明每种典型场景下查询和结果集,用例使用
的建表语句和数据为:
create table t (i1 int,
vc1 varchar(10) masked with (function='partial(2,"*****",0)'),
vc2 varchar(10) masked with (function='partial(2,"*****",0)'));
insert into t values (1, 'nblknabpa', 'pombkaia');
insert into t values (2, '.mapkna', '0jbadflk');
insert into t values ();

示例1:第i 类函数case when 脱敏列规则;
gbase>select case i1 when 1 then vc1 when 2 then '12345' else '67890' end as res
from t;
+---------+
| res |
+---------+
| nb***** |
| 12***** |
| 67***** |
+---------+

示例2:第i 类函数coalesce 脱敏列规则;
gbase>select coalesce(vc1,'12345') as res from t;
+---------+
| res |
+---------+
| nb***** |
| .m***** |
| 12***** |
+---------+

示例3:第i 类函数case when 多脱敏列默认脱敏;

GBase UP 产品手册 5 数据库管理指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 292
gbase>
select case i1 when 1 then vc1 when 2 then vc2 else '67890' end as res from
t;
+------+
| res |
+------+
| xxxx |
| xxxx |
| xxxx |
+------+

示例4:第ii 类函数substring 默认脱敏;
gbase> select substring(vc1, 1, 2) as res from t;
+------+
| res |
+------+
| xx |
| xx |
| NULL |
+------+

示例5:第ii 类函数concat 默认脱敏;
gbase> select concat(vc1,'123') as res from t;
+------+
| res |
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例6:第i 类函数嵌套使用;
gbase> select case when i1 > 1 then coalesce(vc1, '12345') else '67890' end as res
from t;
+---------+
| res |
+---------+
| 67***** |
| .m***** |
| 67***** |
+---------+

示例7:第ii 类函数嵌套使用;

GBase UP 产品手册 5 数据库管理指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 293
gbase> select concat(substring(vc1,1,2),'123') as res from t;
+------+
| res |
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例8:第 i 类和ii 类函数混合嵌套调用;
gbase> select coalesce(substring(vc1,1,2),'12345') as res from t;
(或者select substring(coalesce (vc1, '12345'), 1, 2) as res from t;)
+------+
| res |
+------+
| xxxx |
| xxxx |
| xxxx |
+------+

示例9:子查询内或外调用i 类;
gbase> select res from (select coalesce(vc1,'12345')as res from t) as tmp;
(或者select coalesce(vc1, '12345') as res from (select vc1 from t) as tmp;)
+---------+
| res |
+---------+
| nb***** |
| .m***** |
| 12***** |
+---------+

示例10:子查询内或外调用ii 类;
gbase> select res from (select concat(vc1,'123') as res from t) as tmp;
(或者select concat (vc1, '123') as res from (select vc1 from t) as tmp;)
+------+
| res |
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例11:子查询内外调用i 类;

GBase UP 产品手册 5 数据库管理指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 294
gbase> select case when i1 > 1 then res1 else '67890' end as res from (select
i1,coalesce(vc1, '12345') as res1 from t) as tmp;
+---------+
| res |
+---------+
| 67***** |
| .m***** |
| 67***** |
+---------+

示例12:子查询内外调用ii 类;
gbase> select concat(res1,'123') as res from (select substring(vc1,1,2) as res1
from t) as tmp;
+------+
| res |
+------+
| xxxx |
| xxxx |
| NULL |
+------+

示例13:子查询内外混合调用i 类和ii 类。
gbase> select substring(res1,1,4) as res from (select coalesce(vc1, '12345') as
res1 from t) as tmp;
(或者
gbase> select coalesce(res1, '12345') as res from (select substring(vc1,1,2) a
s res1 from t) as tmp; )
+------+
| res |
+------+
| xxxx |
| xxxx |
| xxxx |
+------+

说明
脱敏列脱敏后如果超过脱敏列的最大长度,则自动截断为脱敏列的最大长度。
比如脱敏列定义为:
mask_col varchar(5) masked with (function ='partial(2,"xxxx",2)')
则值“abcde”理论上应脱敏为“abxxxxde”,脱敏后的长度超过了最大长度5,自动
截断为“abxxx”。

GBase UP 产品手册 5 数据库管理指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 295
脱敏列脱敏后对于一些可设置长度的函数脱敏时也会被截断,比如:
select left(mask_col, 2) from t;
left 函数将使用默认脱敏,理论上应脱敏为“xxxx”,但超过了left 函数设置的最大
长度,所以自动截断为“xx”。
Union、Intersect 和Minus 运算时,对应列的脱敏规则与控制流函数的脱敏规则一致。

比如:
select mask_int_col from t union select mask_int_col as col from t;
将使用mask_int_col 的脱敏规则,而:
select mask_int_col from t union select mask_int_col+1 from t;
将使用默认脱敏。
系统表和视图
概述
GBase UP 中的系统表存在于四个database 中,分别是information_schema, gbase,
gclusterdb 及performance_schema。其中,information_schema 中的信息为元数据信
息,这些信息是通过组织相关对象获得的,不是预先存储的信息;gbase 库存放的
是一些持久化存储的信息,信息存储在gssys 引擎的表中;gclusterdb 存储的是需要
在集群范围保存的信息,
使用的是express 引擎;
performance_schema 存储的是运行
状态信息。