openGauss
的密态支持函数
/
存储过程
本期来介绍密态支持函数
/
存储过程。
openGauss 3.0.0
版本只支持
sql
和
PL/pgsql
两种
语言。由于密态支持存储过程中创建和执行函数
/
存储过程对用户是无感知的,因此使用时
语法和非密态无区别。
密态等值查询支持函数存储过程特性新增了系统表
gs_encrypted_proc
,用于存储参数
返回的原始数据类型。下面来看下一些示例。
创建并执行涉及加密列的函数
/
存储过程
1.
创建密钥,详细步骤请参考使用
gsql
操作密态数据库和使用
JDBC
操作密态数据
库。
https://blog.csdn.net/GaussDB/article/details/124924458
2.
创建加密表。
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
3.
插入数据
openGauss=# insert into creditcard_info values(1, 'Avi',
'1234567890123456');
INSERT 0 1
openGauss=# insert into creditcard_info values(2, 'Eli', '2345678901234567');
INSERT 0 1
4.
创建函数支持密态等值查询。
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
评论