]> granicus.if.org Git - postgresql/blob - src/include/rewrite/rowsecurity.h
Fix column-privilege leak in error-message paths
[postgresql] / src / include / rewrite / rowsecurity.h
1 /* -------------------------------------------------------------------------
2  *
3  * rowsecurity.h
4  *
5  *    prototypes for rewrite/rowsecurity.c and the structures for managing
6  *    the row security policies for relations in relcache.
7  *
8  * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * -------------------------------------------------------------------------
12  */
13 #ifndef ROWSECURITY_H
14 #define ROWSECURITY_H
15
16 #include "nodes/parsenodes.h"
17 #include "utils/array.h"
18 #include "utils/relcache.h"
19
20 typedef struct RowSecurityPolicy
21 {
22         Oid                                     policy_id;              /* OID of the policy */
23         char                       *policy_name;        /* Name of the policy */
24         char                            polcmd;                 /* Type of command policy is for */
25         ArrayType                  *roles;                      /* Array of roles policy is for */
26         Expr                       *qual;                       /* Expression to filter rows */
27         Expr                       *with_check_qual; /* Expression to limit rows allowed */
28         bool                            hassublinks;    /* If either expression has sublinks */
29 } RowSecurityPolicy;
30
31 typedef struct RowSecurityDesc
32 {
33         MemoryContext           rscxt;          /* row security memory context */
34         List                       *policies;   /* list of row security policies */
35 } RowSecurityDesc;
36
37 typedef List *(*row_security_policy_hook_type)(CmdType cmdtype,
38                                                                                            Relation relation);
39
40 extern PGDLLIMPORT row_security_policy_hook_type row_security_policy_hook;
41
42 extern bool prepend_row_security_policies(Query* root, RangeTblEntry* rte,
43                                                                            int rt_index);
44
45 #endif  /* ROWSECURITY_H */