aboutsummaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rowsecurity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/rewrite/rowsecurity.c')
-rw-r--r--src/backend/rewrite/rowsecurity.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/backend/rewrite/rowsecurity.c b/src/backend/rewrite/rowsecurity.c
index e060353bff8..b0b308118f4 100644
--- a/src/backend/rewrite/rowsecurity.c
+++ b/src/backend/rewrite/rowsecurity.c
@@ -259,7 +259,9 @@ get_row_security_policies(Query* root, RangeTblEntry* rte, int rt_index,
WithCheckOption *wco;
wco = (WithCheckOption *) makeNode(WithCheckOption);
- wco->viewname = pstrdup(RelationGetRelationName(rel));
+ wco->kind = root->commandType == CMD_INSERT ? WCO_RLS_INSERT_CHECK :
+ WCO_RLS_UPDATE_CHECK;
+ wco->relname = pstrdup(RelationGetRelationName(rel));
wco->qual = (Node *) hook_with_check_expr_restrictive;
wco->cascaded = false;
*withCheckOptions = lappend(*withCheckOptions, wco);
@@ -274,7 +276,9 @@ get_row_security_policies(Query* root, RangeTblEntry* rte, int rt_index,
WithCheckOption *wco;
wco = (WithCheckOption *) makeNode(WithCheckOption);
- wco->viewname = pstrdup(RelationGetRelationName(rel));
+ wco->kind = root->commandType == CMD_INSERT ? WCO_RLS_INSERT_CHECK :
+ WCO_RLS_UPDATE_CHECK;
+ wco->relname = pstrdup(RelationGetRelationName(rel));
wco->qual = (Node *) rowsec_with_check_expr;
wco->cascaded = false;
*withCheckOptions = lappend(*withCheckOptions, wco);
@@ -285,7 +289,9 @@ get_row_security_policies(Query* root, RangeTblEntry* rte, int rt_index,
WithCheckOption *wco;
wco = (WithCheckOption *) makeNode(WithCheckOption);
- wco->viewname = pstrdup(RelationGetRelationName(rel));
+ wco->kind = root->commandType == CMD_INSERT ? WCO_RLS_INSERT_CHECK :
+ WCO_RLS_UPDATE_CHECK;
+ wco->relname = pstrdup(RelationGetRelationName(rel));
wco->qual = (Node *) hook_with_check_expr_permissive;
wco->cascaded = false;
*withCheckOptions = lappend(*withCheckOptions, wco);
@@ -297,13 +303,18 @@ get_row_security_policies(Query* root, RangeTblEntry* rte, int rt_index,
List *combined_quals = NIL;
Expr *combined_qual_eval;
- combined_quals = lcons(copyObject(rowsec_with_check_expr), combined_quals);
- combined_quals = lcons(copyObject(hook_with_check_expr_permissive), combined_quals);
+ combined_quals = lcons(copyObject(rowsec_with_check_expr),
+ combined_quals);
+
+ combined_quals = lcons(copyObject(hook_with_check_expr_permissive),
+ combined_quals);
combined_qual_eval = makeBoolExpr(OR_EXPR, combined_quals, -1);
wco = (WithCheckOption *) makeNode(WithCheckOption);
- wco->viewname = pstrdup(RelationGetRelationName(rel));
+ wco->kind = root->commandType == CMD_INSERT ? WCO_RLS_INSERT_CHECK :
+ WCO_RLS_UPDATE_CHECK;
+ wco->relname = pstrdup(RelationGetRelationName(rel));
wco->qual = (Node *) combined_qual_eval;
wco->cascaded = false;
*withCheckOptions = lappend(*withCheckOptions, wco);
@@ -332,7 +343,8 @@ get_row_security_policies(Query* root, RangeTblEntry* rte, int rt_index,
Expr *combined_qual_eval;
combined_quals = lcons(copyObject(rowsec_expr), combined_quals);
- combined_quals = lcons(copyObject(hook_expr_permissive), combined_quals);
+ combined_quals = lcons(copyObject(hook_expr_permissive),
+ combined_quals);
combined_qual_eval = makeBoolExpr(OR_EXPR, combined_quals, -1);