当前位置:网站首页>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中并没有提供已定义者身份执行的这种方式。
边栏推荐
- 转行软件测试,知道这四点就够了!
- Leetcode(34)——在排序数组中查找元素的第一个和最后一个位置
- win 10 mstsc连接 RemoteApp
- Linux foundation - centos7 offline installation of MySQL
- Force buckle 710 Random numbers in the blacklist
- 想请教股票开户要认识谁?在线开户是安全么?
- Which securities company is better and which is safer to open a securities account
- Compare the version number [double pointer to intercept the string you want]
- Matplotlib常用图表
- mysql ---- Oracle中的rownum转换成MySQL
猜你喜欢

Yunxin small class | common cognitive misunderstandings in IM and audio and video

What is mosaic?

Matplotlib常用图表

纪念成为首个DAYUs200三方demo贡献者

Experience of practical learning of Silicon Valley products

Matplotlib常用設置

from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘

Detailed explanation of twenty common software testing methods (the most complete in History)

【微服务|Sentinel】sentinel整合openfeign

YOGA27多维一体电脑,兼具出色外观与高端配置
随机推荐
[机缘参悟-35]:鬼谷子-飞箝篇-远程连接、远程控制与远程测试之术
CADD课程学习(3)-- 靶点药物相互作用
Redis~02 缓存:更新数据时如何保证MySQL和Redis中的数据一致性?
硅谷产品实战学习感触
物联网技术应用属于什么专业分类
y53.第三章 Kubernetes从入门到精通 -- ingress(二六)
日本购物网站的网络乞丐功能
Commemorate becoming the first dayus200 tripartite demo contributor
共享电商的背后: 共创、共生、共享、共富,共赢的共富精神
赵福全:短期解决保供,长期要打造安全、高效有韧性的供应链
Treatment of insufficient space in the root partition of armbain system
CKS CKA CKAD 将终端更改为远程桌面
Yunxin small class | common cognitive misunderstandings in IM and audio and video
What is mosaic?
Y53. Chapter III kubernetes from introduction to mastery -- ingress (26)
Development trend and future direction of neural network Internet of things
众昂矿业:发展以氟化工为主的特色化工产业具有先天优势
ShanDong Multi-University Training #3
Matplotlib常用設置
Jerry's question about long press boot detection [chapter]