当前位置:网站首页>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中并没有提供已定义者身份执行的这种方式。
边栏推荐
- Why is PHP called hypertext preprocessor
- Jielizhi, production line assembly link [chapter]
- 众昂矿业:发展以氟化工为主的特色化工产业具有先天优势
- Redis~02 cache: how to ensure data consistency in MySQL and redis when updating data?
- Advanced skills of testers: a guide to the application of unit test reports
- Current situation and future development trend of Internet of things
- 软件架构的本质
- 2022 crane driver (limited to bridge crane) examination questions and simulation examination
- The difference between timer and scheduledthreadpoolexecutor
- Paramètres communs de matplotlib
猜你喜欢

rviz打开后如何显示实时2D地图

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

Commemorate becoming the first dayus200 tripartite demo contributor

What category does the Internet of things application technology major belong to

Development trend and future direction of neural network Internet of things

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

Redis数据类型和应用场景

MT manager test skiing Adventure

MySQL binlog cleanup

2022年危险化学品经营单位安全管理人员考试题及在线模拟考试
随机推荐
typescript枚举
问题随记 —— /usr/bin/perl is needed by MySQL-server-5.1.73-1.glibc23.x86_64
Force buckle 710 Random numbers in the blacklist
Detailed explanation of twenty common software testing methods (the most complete in History)
纪念成为首个DAYUs200三方demo贡献者
每日三题 6.28
What is the relationship between modeling and later film and television?
Typescript enumeration
Glass mosaic
Airserver latest win64 bit personal screen projection software
会声会影2022智能、快速、简单的视频剪辑软件
[MySQL] index creation, viewing and deletion
Notes to problems - file /usr/share/mysql/charsets/readme from install of mysql-server-5.1.73-1 glibc23.x86_ 64 c
JS - use of arguments
Daily three questions 6.30
AirServer最新Win64位个人版投屏软件
What is the mosaic tailgate?
Who do you want to know when opening a stock account? Is it safe to open an account online?
Understanding threads
plain framework的实际应用和扩展