当前位置:网站首页>Understand the dense support functions / stored procedures of opengauss
Understand the dense support functions / stored procedures of opengauss
2022-06-11 15:50:00 【Gauss squirrel Club】
In the last issue, we introduced the secret query and usage jdbc The operation of connecting to the dense database . In this issue, we will introduce the dense state support function / stored procedure .openGauss 3.0.0 Version support only sql and PL/pgsql Two languages . Because the secret state supports the creation and execution of functions in stored procedures / Stored procedures are insensitive to users , Therefore, there is no difference between syntax and unclassified state .
The stored procedure feature of the dense equivalent query support function adds a system table gs_encrypted_proc, Used to store the original data type returned by the parameter . Here are some examples .
Create and execute functions involving encrypted Columns / stored procedure
Create key , Please refer to Use gsql Operate the dense database and use JDBC Operating dense database .
Create encryption table .
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
- insert data .
openGauss=# insert into creditcard_info values(1, 'Avi', '1234567890123456');
INSERT 0 1
openGauss=# insert into creditcard_info values(2, 'Eli', '2345678901234567');
INSERT 0 1
- The creation function supports dense equivalent query .
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
- Execute 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)
However, there are some precautions when using .
- function / In a stored procedure “ Execute dynamic query statement ” Queries in are compiled during execution , So function / Table name in stored procedure 、 The column name cannot be unknown at the creation stage , Input parameters cannot be used for table names 、 Column name or connect in any way .
- stay RETURNS、IN and OUT The parameters of the , Mixing encrypted and unencrypted type parameters is not supported . Although the parameter types are original data types , But the actual type is different .
- For high-level package interface , Such as dbe_output.print_line() The interface waiting for the server printout will not decrypt , When the encrypted data type is forcibly converted to the plaintext original data type, the default value of the data type will be printed .
- Function of current version / Stored procedure's LANGUAGE Only support SQL and PL/pgSQL, I won't support it C and JAVA Other process languages .
- Not supported in function / Execute other functions in the stored procedure to query the encrypted column / stored procedure .
- Current version not supported default、DECLARE Assign default values to variables in , And does not support DECLARE Decrypt the return value in , The user can use the input parameters when executing the function 、 Output parameters instead of using .
- I won't support it gs_dump For those involving encrypted Columns function Make a backup .
- Not supported in function / Create a key in a stored procedure .
- This version of dense state function / Stored procedures do not support triggers .
- Dense equivalent query function / Stored procedures do not support for plpgsql Language escapes grammar , For syntax with quotation marks in the main body CREATE FUNCTION AS ‘ Grammatical subject ’, It can be used CREATE FUNCTION AS ‘ Grammatical subject ’ Instead of .
- The dense equivalent query function is not supported / Perform the operation of modifying the encrypted column definition in the stored procedure , Including creating encrypted tables 、 Add encrypted Columns , Because the execution function is on the server side , The client cannot determine whether it needs to refresh the cache , The column can be encrypted only after the connection is disconnected or the client encryption column cache is refreshed .
边栏推荐
- CF662B Graph Coloring题解--zhengjun
- 三千字教你使用MOT
- Db4ai: database driven AI
- 2022.02.28
- After nine years of testing, the salary for interviewing Huawei is 10000. Huawei employees: the company doesn't have such a low salary position
- dapr 思维导图
- 从0到1稳稳掌握大厂主流技术,年后涨薪不是必须的吗?
- 了解下openGauss的密态支持函数/存储过程
- openGauss 3.0.0版本正式发布,立即体验社区首个轻量版本
- Charles自动保存响应数据
猜你喜欢

3000 words to teach you how to use mot

关于 JS 函数的一切

拿到20K我用了5年,面了所有大厂,这些高频面试问题都帮你们划出来啦

Learn automatic testing of postman interface from 0 to 1

The third generation Pentium B70 won the C-NCAP five-star safety performance again
![[creation mode] abstract factory mode](/img/16/d0086ba4cceb1c174d3f88ef5448e6.png)
[creation mode] abstract factory mode

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

【0006】title、關鍵字及頁面描述
![[creation mode] prototype mode](/img/2b/5e6f4f9ca0718221ee1383243b794f.png)
[creation mode] prototype mode
![[creation mode] builder mode](/img/8d/989c69772502a3ccda320025236e46.png)
[creation mode] builder mode
随机推荐
After nine years of testing, the salary for interviewing Huawei is 10000. Huawei employees: the company doesn't have such a low salary position
同学,你听说过MOT吗?
关于 JS 函数的一切
数据库设计建议
Import data to the database? Try the copy from stdin statement
Export configuration to FTP or TFTP server
Find combination number (function)
码农必备SQL调优(上)
如何管理并发写入操作?带你快速上手
3000 words to teach you how to use mot
Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container..
带你深度了解AGC云数据库
Tianjin Port coke wharf hand in hand map flapping software to visually unlock the smart coke port
Go language - array
Thales cloud security report shows that cloud data leakage and complexity are on the rise
Implementation of placing the scroll bar on the top of the uniapp
Analysis of breadcrumb usage scenarios on websites
2022年软件测试的前景如何?需不需要懂代码?
How to write elegant secondary classification for enterprise development [small case of meituan]
三千字教你使用MOT