当前位置:网站首页>Oracle中已定义者身份执行函数AUTHID DEFINER与Postgresql行为的异同
Oracle中已定义者身份执行函数AUTHID DEFINER与Postgresql行为的异同
2022-07-01 22:57:00 【mingjie73】
Oracle行为
Oracle中函数可以定义执行函数体时,使用哪个用户的权限:
[AUTHID { CURRENT_USER|DEFINER}]
CURRENT_USER已当前用户身份执行函数体
DEFINER已定义者的身份执行函数体
CASE1:例如下面函数会使用当前用户执行函数体,如果当前用户对tbl1读权限就可以成功执行。
CREATE OR REPLACE PROCEDURE TEST_P AUTHID CURRENT_USER IS
BEGIN
EXECUTE IMMEDIATE 'select * from tbl1';
END TEST_P;
CASE2:下面函数会使用定义函数的用户执行函数体,如果定义函数的用户对tbl1读权限就可以成功执行。
CREATE OR REPLACE PROCEDURE TEST_P AUTHID DEFINER IS
BEGIN
EXECUTE IMMEDIATE 'select * from tbl1';
END TEST_P;
PG 行为
PG中执行函数永远是使用当前用户的权限来执行的,类似Oracle中AUTHID CURRENT_USER的概念。
例如user1创建表
drop table u1tbl;
create table u1tbl(i int);
insert into u1tbl values (123);
user2无权限查询
postgres=> select * from u1tbl;
ERROR: permission denied for table u1tbl
user1创建函数
drop function f1();
CREATE OR REPLACE FUNCTION f1() RETURNS int AS $$
DECLARE
id int;
BEGIN
select i into id from u1tbl;
return id;
END;
$$ LANGUAGE plpgsql;
user2执行函数
postgres=> select f1();
ERROR: permission denied for table u1tbl
CONTEXT: SQL statement "select i from u1tbl"
PL/pgSQL function f1() line 5 at SQL statement
可见PG中并没有提供已定义者身份执行的这种方式。
边栏推荐
猜你喜欢

Redis~02 缓存:更新数据时如何保证MySQL和Redis中的数据一致性?
![[applet] realize the left and right [sliding] list through the scroll view component](/img/18/b1b4e9923782856143721dad84cbab.png)
[applet] realize the left and right [sliding] list through the scroll view component

玻璃马赛克

Some abilities can't be learned from work. Look at this article, more than 90% of peers

Notes to problems - file /usr/share/mysql/charsets/readme from install of mysql-server-5.1.73-1 glibc23.x86_ 64 c
![Jielizhi Bluetooth headset quality control and production skills [chapter]](/img/3e/571d246d211a979e948dae1de56e93.png)
Jielizhi Bluetooth headset quality control and production skills [chapter]

flutter Unable to load asset: assets/images/888. png

SWT/ANR问题--SWT 导致 kernel fuse deadlock

Istio, ebpf and rsocket Broker: in depth study of service grid

flutter Unable to load asset: assets/images/888.png
随机推荐
Detailed explanation of twenty common software testing methods (the most complete in History)
JS - use of arguments
What is the mosaic tailgate?
关于游戏性能优化的一些感想
mt管理器测试滑雪大冒险
Who do you want to know when opening a stock account? Is it safe to open an account online?
Glass mosaic
SWT/ANR问题--SWT 导致 kernel fuse deadlock
Jerry's burning of upper version materials requires [chapter]
The difference between timer and scheduledthreadpoolexecutor
Jerry's records are powered by Vbat with a power supply voltage of 4.2V [chapter]
CKS CKA ckad change terminal to remote desktop
Win 10 mstsc connect RemoteApp
马赛克后挡板是什么?
Why is PHP called hypertext preprocessor
Daily three questions 6.29
Jielizhi Bluetooth headset quality control and production skills [chapter]
De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
Distance measurement - Hamming distance
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification