postgresql9.6中的 Row Security Policies

来源:互联网 发布:visio中文版mac下载 编辑:程序博客网 时间:2024/06/15 05:20

1.。中文VS2008下面编译pg9.6

修改VSObjectFactory.pm 中的 DetermineVisualStudioVersion 直接 return '9.00';


2.。在 ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;时

a )  在函数 ATExecEnableRowSecurity 把pg_class中的 relrowsecurity 置为 true


3。CREATE POLICY account_managers ON accounts TO managers USING (manager = current_user);

对系统表pg_policy增加了一条记录

#define PolicyRelationId 3256

CATALOG(pg_policy,3256)
{
 NameData polname;  /* Policy name. */
 Oid   polrelid;  /* Oid of the relation with policy. */
 char  polcmd;   /* One of ACL_*_CHR, or '*' for all */

#ifdef CATALOG_VARLEN
 Oid   polroles[1]; /* Roles associated with policy, not-NULL */
 pg_node_tree polqual;  /* Policy quals. */
 pg_node_tree polwithcheck; /* WITH CHECK quals. */
#endif
} FormData_pg_policy;


4。使用时,就是在select或是insert时,把rewirte阶段,把polqual 和 polwithcheck 加到后面,之后在执行时进行判断

rewrite调用的函数 get_row_security_policies

执行时调用函数 ExecWithCheckOptions、ExecWithCheckOptions



和MAC的区别

1。没有等级和范围的概念

2。管理员还是可以看到全部数据

3。MAC特权概念不明显

4。Row Security Policies 需要在用户表的设计时加上限制的字段,需要改应用






0 0