summaryrefslogtreecommitdiff
path: root/src/backend/rewrite/locks.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/rewrite/locks.c')
-rw-r--r--src/backend/rewrite/locks.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/backend/rewrite/locks.c b/src/backend/rewrite/locks.c
index 0d438a3ddcd..f57a4364207 100644
--- a/src/backend/rewrite/locks.c
+++ b/src/backend/rewrite/locks.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.12 1998/09/01 03:24:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.13 1998/09/01 04:31:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -175,12 +175,12 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
{
Relation ev_rel;
HeapTuple usertup;
- char *evowner;
- RangeTblEntry *rte;
+ char *evowner;
+ RangeTblEntry *rte;
int32 reqperm;
int32 aclcheck_res;
- int i;
- List *l;
+ int i;
+ List *l;
if (locks == NIL)
return;
@@ -188,11 +188,11 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
/*
* Get the usename of the rules event relation owner
*/
- rte = (RangeTblEntry *)nth(rt_index - 1, parsetree->rtable);
+ rte = (RangeTblEntry *) nth(rt_index - 1, parsetree->rtable);
ev_rel = heap_openr(rte->relname);
usertup = SearchSysCacheTuple(USESYSID,
- ObjectIdGetDatum(ev_rel->rd_rel->relowner),
- 0, 0, 0);
+ ObjectIdGetDatum(ev_rel->rd_rel->relowner),
+ 0, 0, 0);
if (!HeapTupleIsValid(usertup))
{
elog(ERROR, "cache lookup for userid %d failed",
@@ -200,29 +200,32 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
}
heap_close(ev_rel);
evowner = nameout(&(((Form_pg_shadow) GETSTRUCT(usertup))->usename));
-
+
/*
* Check all the locks, that should get fired on this query
*/
- foreach (l, locks) {
- RewriteRule *onelock = (RewriteRule *)lfirst(l);
- List *action;
+ foreach(l, locks)
+ {
+ RewriteRule *onelock = (RewriteRule *) lfirst(l);
+ List *action;
/*
* In each lock check every action
*/
- foreach (action, onelock->actions) {
- Query *query = (Query *)lfirst(action);
+ foreach(action, onelock->actions)
+ {
+ Query *query = (Query *) lfirst(action);
/*
- * In each action check every rangetable entry
- * for read/write permission of the event relations
- * owner depending on if it's the result relation
- * (write) or not (read)
+ * In each action check every rangetable entry for read/write
+ * permission of the event relations owner depending on if
+ * it's the result relation (write) or not (read)
*/
- for (i = 2; i < length(query->rtable); i++) {
+ for (i = 2; i < length(query->rtable); i++)
+ {
if (i + 1 == query->resultRelation)
- switch (query->resultRelation) {
+ switch (query->resultRelation)
+ {
case CMD_INSERT:
reqperm = ACL_AP;
break;
@@ -233,19 +236,19 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
else
reqperm = ACL_RD;
- rte = (RangeTblEntry *)nth(i, query->rtable);
- aclcheck_res = pg_aclcheck(rte->relname,
- evowner, reqperm);
- if (aclcheck_res != ACLCHECK_OK) {
- elog(ERROR, "%s: %s",
- rte->relname,
- aclcheck_error_strings[aclcheck_res]);
+ rte = (RangeTblEntry *) nth(i, query->rtable);
+ aclcheck_res = pg_aclcheck(rte->relname,
+ evowner, reqperm);
+ if (aclcheck_res != ACLCHECK_OK)
+ {
+ elog(ERROR, "%s: %s",
+ rte->relname,
+ aclcheck_error_strings[aclcheck_res]);
}
/*
- * So this is allowed due to the permissions
- * of the rules event relation owner. But
- * let's see if the next one too
+ * So this is allowed due to the permissions of the rules
+ * event relation owner. But let's see if the next one too
*/
rte->skipAcl = TRUE;
}
@@ -257,5 +260,3 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
*/
return;
}
-
-