当前位置:网站首页>了解下openGauss的密态支持函数/存储过程
了解下openGauss的密态支持函数/存储过程
2022-06-11 15:36:00 【Gauss松鼠会】
上期我们介绍了密态查询和使用jdbc连接密态数据库的操作。本期来介绍密态支持函数/存储过程。openGauss 3.0.0版本只支持sql和PL/pgsql两种语言。由于密态支持存储过程中创建和执行函数/存储过程对用户是无感知的,因此使用时语法和非密态无区别。
密态等值查询支持函数存储过程特性新增了系统表gs_encrypted_proc,用于存储参数返回的原始数据类型。下面来看下一些示例。
创建并执行涉及加密列的函数/存储过程
创建密钥,详细步骤请参考使用gsql操作密态数据库和使用JDBC操作密态数据库。
创建加密表。
openGauss=# CREATE TABLE creditcard_info (
id_number int,
name text,
credit_card varchar(19) encrypted with (column_encryption_key = ImgCEK1, encryption_type = DETERMINISTIC)
) with (orientation=row);
CREATE TABLE
- 插入数据。
openGauss=# insert into creditcard_info values(1, 'Avi', '1234567890123456');
INSERT 0 1
openGauss=# insert into creditcard_info values(2, 'Eli', '2345678901234567');
INSERT 0 1
- 创建函数支持密态等值查询。
openGauss=# CREATE FUNCTION f_encrypt_in_sql(val1 text, val2 varchar(19)) RETURNS text AS 'SELECT name from creditcard_info where name=$1 or credit_card=$2 LIMIT 1' LANGUAGE SQL;
CREATE FUNCTION
openGauss=# CREATE FUNCTION f_encrypt_in_plpgsql (val1 text, val2 varchar(19))
RETURNS text AS $$
DECLARE
c text;
BEGIN
SELECT into c name from creditcard_info where name=$1 or credit_card =$2 LIMIT 1;
RETURN c;
END; $$
LANGUAGE plpgsql;
CREATE FUNCTION
- 执行函数。
openGauss=# SELECT f_encrypt_in_sql('Avi','1234567890123456');
f_encrypt_in_sql
------------------
Avi
(1 row)
openGauss=# SELECT f_encrypt_in_plpgsql('Avi', val2=>'1234567890123456');
f_encrypt_in_plpgsql
----------------------
Avi
(1 row)
不过在使用的时候有些注意事项。
- 函数/存储过程中的“执行动态查询语句”中的查询是在执行过程中编译,因此函数/存储过程中的表名、列名不能在创建阶段未知,输入参数不能用于表名、列名或以任何方式连接。
- 在RETURNS、IN和OUT的参数中,不支持混合使用加密和非加密类型参数。虽然参数类型都是原始数据类型,但实际类型不同。
- 对高级包接口中,如dbe_output.print_line()等在服务端打印输出的接口不会做解密操作,加密数据类型在强转成明文原始数据类型时会打印出该数据类型的默认值。
- 当前版本函数/存储过程的LANGUAGE只支持SQL和PL/pgSQL,不支持C和JAVA等其他过程语言。
- 不支持在函数/存储过程中执行其他查询加密列的函数/存储过程。
- 当前版本不支持default、DECLARE中为变量赋予默认值,且不支持对DECLARE中的返回值进行解密,用户可以用执行函数时用输入参数、输出参数来代替使用。
- 不支持gs_dump对涉及加密列的function进行备份。
- 不支持在函数/存储过程中创建密钥。
- 该版本密态函数/存储过程不支持触发器。
- 密态等值查询函数/存储过程不支持对plpgsql语言对语法进行转义,对于语法主体带有引号的语法CREATE FUNCTION AS ‘语法主体’, 可以用CREATE FUNCTION AS ‘语法主体’ 代替。
- 不支持在密态等值查询函数/存储过程中执行修改加密列定义的操作,包括创建加密表、添加加密列,由于执行函数是在服务端,客户端没法判断是否是需要刷新缓存,得断开连接后或触发刷新客户端加密列缓存才可以对该列做加密操作。
边栏推荐
- Knowledge of affairs
- 知网被立案调查;字节跳动成立抖音集团,或在港上市;钉钉被曝裁员30%;北京人均存款超20万元 |Q资讯
- [creation mode] prototype mode
- 英伟达终于开源GPU内核模块代码,网友:难以置信
- uniapp滚动条置顶实现
- [creation mode] abstract factory mode
- Hot seek tiger, a list of eco economic models
- What is excess product power? Find the secret key of the second generation cs75plus in the year of the tiger
- [process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle
- 19. 二叉搜索树的插入删除修剪
猜你喜欢

04 _ In simple terms index (I)

19. 二叉搜索樹的插入删除修剪

How to play seek tiger, which has attracted much attention in the market?
![[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle](/img/c7/ff28df36b8d5dda704aa829dd5264f.png)
[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle

Is it possible to use multiple indexes together in a query?

Design and implementation of data analysis system

【创建型模式】工厂方法模式

19. Insertion et suppression d'un arbre de recherche binaire

2022.02.28

Art plus online school: Sketch common sitting posture test questions, these three angles must be mastered~
随机推荐
[multi thread performance tuning] what operations cause context switching?
[creation mode] factory method mode
Unified record of my code variable names
Find combination number (function)
[mysql_12] MySQL data types
uniapp滚动条置顶实现
Installation and use of sonarqube
Learn more about and use ThreadLocal
Introduction to JVM basic concepts
Everything about JS functions
05 _ In simple terms index (Part 2)
How about art plus online school? Is it a new online organization?
Lick the dog till the last one has nothing (linear DP)
你还不懂线程池的设计及原理吗?掰开揉碎了教你设计线程池
英伟达终于开源GPU内核模块代码,网友:难以置信
What is excess product power? Find the secret key of the second generation cs75plus in the year of the tiger
Art plus online school: Sketch common sitting posture test questions, these three angles must be mastered~
Mysql database optimization details
微软韦青:狗尾巴的故事—数智时代的第一性原理 | 极客时间
2022 Tibet's latest junior firefighter simulation test question bank and answers