从PostgreSQL 15开始,可以在视图上设置security_invoker
。我想知道如何检查我的视图是否启用了它,因为pgAdmin和DataGrip都没有显示。
下面是检查public
模式中所有视图的示例:
select
relname,
case
when lower(reloptions::text)::text[] && array['security_invoker=1','security_invoker=true','security_invoker=on']
then true else false
end as security_invoker
from pg_class
join pg_catalog.pg_namespace n on n.oid = pg_class.relnamespace
where n.nspname = 'public' and relkind='v';
在内部pg_class
表中,有一列称为reloptions
,它知道security_invoker
是否打开。
reloptions
的输出示例:如果{security_invoker=true}
和{security_invoker=on}
未打开,则默认为null
。