catalog-pg-policy.md 2.9 KB
Newer Older
K
KyleZhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
## 52.37. `pg_policy`

[]()

 The catalog `pg_policy` stores row-level security policies for tables. A policy includes the kind of command that it applies to (possibly all commands), the roles that it applies to, the expression to be added as a security-barrier qualification to queries that include the table, and the expression to be added as a `WITH CHECK` option for queries that attempt to add new records to the table.

**Table 52.37. `pg_policy` Columns**

|                                                                                                  Column Type<br/><br/> Description                                                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                `oid` `oid`<br/><br/> Row identifier                                                                                                 |
|                                                                                          `polname` `name`<br/><br/> The name of the policy                                                                                          |
|                                                       `polrelid` `oid` (references [`pg_class`](catalog-pg-class.html).`oid`)<br/><br/> The table to which the policy applies                                                       |
|`polcmd` `char`<br/><br/> The command type to which the policy is applied: `r` for [SELECT](sql-select.html), `a` for [INSERT](sql-insert.html), `w` for [UPDATE](sql-update.html), `d` for [DELETE](sql-delete.html), or `*` for all|
|                                                                              `polpermissive` `bool`<br/><br/> Is the policy permissive or restrictive?                                                                              |
|                    `polroles` `oid[]` (references [`pg_authid`](catalog-pg-authid.html).`oid`)<br/><br/> The roles to which the policy is applied; zero means `PUBLIC` (and normally appears alone in the array)                    |
|                                              `polqual` `pg_node_tree`<br/><br/> The expression tree to be added to the security barrier qualifications for queries that use the table                                               |
|                                     `polwithcheck` `pg_node_tree`<br/><br/> The expression tree to be added to the WITH CHECK qualifications for queries that attempt to add rows to the table                                      |

### Note

 Policies stored in `pg_policy` are applied only when [`pg_class`](catalog-pg-class.html).`relrowsecurity` is set for their table.