diff options
Diffstat (limited to 'src/backend/rewrite')
-rw-r--r-- | src/backend/rewrite/rewriteDefine.c | 60 | ||||
-rw-r--r-- | src/backend/rewrite/rewriteHandler.c | 123 | ||||
-rw-r--r-- | src/backend/rewrite/rewriteManip.c | 91 | ||||
-rw-r--r-- | src/backend/rewrite/rewriteRemove.c | 19 | ||||
-rw-r--r-- | src/backend/rewrite/rewriteSupport.c | 5 |
5 files changed, 153 insertions, 145 deletions
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index d470cb9fe7..316b18316c 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.58 2001/01/24 19:43:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.59 2001/03/22 03:59:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,9 +175,10 @@ DefineQueryRewrite(RuleStmt *stmt) /* * If we are installing an ON SELECT rule, we had better grab * AccessExclusiveLock to ensure no SELECTs are currently running on - * the event relation. For other types of rules, it might be sufficient - * to grab ShareLock to lock out insert/update/delete actions. But - * for now, let's just grab AccessExclusiveLock all the time. + * the event relation. For other types of rules, it might be + * sufficient to grab ShareLock to lock out insert/update/delete + * actions. But for now, let's just grab AccessExclusiveLock all the + * time. */ event_relation = heap_openr(event_obj->relname, AccessExclusiveLock); ev_relid = RelationGetRelid(event_relation); @@ -226,7 +227,7 @@ DefineQueryRewrite(RuleStmt *stmt) { List *tllist; int i; - char *expected_name; + char *expected_name; /* * So there cannot be INSTEAD NOTHING, ... @@ -285,9 +286,10 @@ DefineQueryRewrite(RuleStmt *stmt) /* * Allow typmods to be different only if one of them is -1, - * ie, "unspecified". This is necessary for cases like "numeric", - * where the table will have a filled-in default length but the - * select rule's expression will probably have typmod = -1. + * ie, "unspecified". This is necessary for cases like + * "numeric", where the table will have a filled-in default + * length but the select rule's expression will probably have + * typmod = -1. */ if (attr->atttypmod != resdom->restypmod && attr->atttypmod != -1 && resdom->restypmod != -1) @@ -327,13 +329,13 @@ DefineQueryRewrite(RuleStmt *stmt) /* * Are we converting a relation to a view? * - * If so, check that the relation is empty because the storage - * for the relation is going to be deleted. + * If so, check that the relation is empty because the storage for + * the relation is going to be deleted. */ if (event_relation->rd_rel->relkind != RELKIND_VIEW) { - HeapScanDesc scanDesc; - HeapTuple tuple; + HeapScanDesc scanDesc; + HeapTuple tuple; scanDesc = heap_beginscan(event_relation, 0, SnapshotNow, 0, NULL); tuple = heap_getnext(scanDesc, 0); @@ -341,7 +343,10 @@ DefineQueryRewrite(RuleStmt *stmt) elog(ERROR, "Relation \"%s\" is not empty. Cannot convert it to view", event_obj->relname); - /* don't need heap_freetuple because we never got a valid tuple */ + /* + * don't need heap_freetuple because we never got a valid + * tuple + */ heap_endscan(scanDesc); RelisBecomingView = true; @@ -368,10 +373,10 @@ DefineQueryRewrite(RuleStmt *stmt) is_instead, event_attype); /* - * We want the rule's table references to be checked as though by - * the rule owner, not the user referencing the rule. Therefore, - * scan through the rule's rtables and set the checkAsUser field - * on all rtable entries (except *OLD* and *NEW*). + * We want the rule's table references to be checked as though by the + * rule owner, not the user referencing the rule. Therefore, scan + * through the rule's rtables and set the checkAsUser field on all + * rtable entries (except *OLD* and *NEW*). */ foreach(l, action) { @@ -394,21 +399,21 @@ DefineQueryRewrite(RuleStmt *stmt) actionP); /* - * Set pg_class 'relhasrules' field TRUE for event relation. - * If appropriate, also modify the 'relkind' field to show that - * the relation is now a view. + * Set pg_class 'relhasrules' field TRUE for event relation. If + * appropriate, also modify the 'relkind' field to show that the + * relation is now a view. * * Important side effect: an SI notice is broadcast to force all - * backends (including me!) to update relcache entries with the new - * rule. + * backends (including me!) to update relcache entries with the + * new rule. */ SetRelationRuleStatus(ev_relid, true, RelisBecomingView); } /* - * IF the relation is becoming a view, delete the storage - * files associated with it. NB: we had better have AccessExclusiveLock - * to do this ... + * IF the relation is becoming a view, delete the storage files + * associated with it. NB: we had better have AccessExclusiveLock to + * do this ... */ if (RelisBecomingView) smgrunlink(DEFAULT_SMGR, event_relation); @@ -439,21 +444,20 @@ setRuleCheckAsUser(Query *qry, Oid userid) if (rte->subquery) { + /* * Recurse into subquery in FROM */ setRuleCheckAsUser(rte->subquery, userid); } else - { rte->checkAsUser = userid; - } } /* If there are sublinks, search for them and process their RTEs */ if (qry->hasSubLinks) query_tree_walker(qry, setRuleCheckAsUser_walker, (void *) &userid, - false /* already did the ones in rtable */); + false /* already did the ones in rtable */ ); } /* diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 505d5f4350..6ece2ae938 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.89 2001/01/27 04:40:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.90 2001/03/22 03:59:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ static RewriteInfo *gatherRewriteMeta(Query *parsetree, static List *adjustJoinTreeList(Query *parsetree, bool removert, int rt_index); static void markQueryForUpdate(Query *qry, bool skipOldNew); static List *matchLocks(CmdType event, RuleLock *rulelocks, - int varno, Query *parsetree); + int varno, Query *parsetree); static Query *fireRIRrules(Query *parsetree); @@ -84,9 +84,9 @@ gatherRewriteMeta(Query *parsetree, * Adjust rule action and qual to offset its varnos, so that we can * merge its rtable into the main parsetree's rtable. * - * If the rule action is an INSERT...SELECT, the OLD/NEW rtable - * entries will be in the SELECT part, and we have to modify that - * rather than the top-level INSERT (kluge!). + * If the rule action is an INSERT...SELECT, the OLD/NEW rtable entries + * will be in the SELECT part, and we have to modify that rather than + * the top-level INSERT (kluge!). */ sub_action = getInsertSelectQuery(info->rule_action, &sub_action_ptr); @@ -101,14 +101,14 @@ gatherRewriteMeta(Query *parsetree, /* * We want the main parsetree's rtable to end up as the concatenation * of its original contents plus those of all the relevant rule - * actions. Also store same into all the rule_action rtables. - * Some of the entries may be unused after we finish rewriting, but - * if we tried to clean those out we'd have a much harder job to - * adjust RT indexes in the query's Vars. It's OK to have unused - * RT entries, since planner will ignore them. + * actions. Also store same into all the rule_action rtables. Some of + * the entries may be unused after we finish rewriting, but if we + * tried to clean those out we'd have a much harder job to adjust RT + * indexes in the query's Vars. It's OK to have unused RT entries, + * since planner will ignore them. * - * NOTE KLUGY HACK: we assume the parsetree rtable had at least one - * entry to begin with (OK enough, else where'd the rule come from?). + * NOTE KLUGY HACK: we assume the parsetree rtable had at least one entry + * to begin with (OK enough, else where'd the rule come from?). * Because of this, if multiple rules nconc() their rtable additions * onto parsetree->rtable, they'll all see the same rtable because * they all have the same list head pointer. @@ -119,24 +119,25 @@ gatherRewriteMeta(Query *parsetree, /* * Each rule action's jointree should be the main parsetree's jointree - * plus that rule's jointree, but usually *without* the original rtindex - * that we're replacing (if present, which it won't be for INSERT). - * Note that if the rule action refers to OLD, its jointree will add - * a reference to rt_index. If the rule action doesn't refer to OLD, - * but either the rule_qual or the user query quals do, then we need to - * keep the original rtindex in the jointree to provide data for the - * quals. We don't want the original rtindex to be joined twice, - * however, so avoid keeping it if the rule action mentions it. + * plus that rule's jointree, but usually *without* the original + * rtindex that we're replacing (if present, which it won't be for + * INSERT). Note that if the rule action refers to OLD, its jointree + * will add a reference to rt_index. If the rule action doesn't refer + * to OLD, but either the rule_qual or the user query quals do, then + * we need to keep the original rtindex in the jointree to provide + * data for the quals. We don't want the original rtindex to be + * joined twice, however, so avoid keeping it if the rule action + * mentions it. */ if (sub_action->jointree != NULL) { - bool keeporig; - List *newjointree; + bool keeporig; + List *newjointree; - keeporig = (! rangeTableEntry_used((Node *) sub_action->jointree, - rt_index, 0)) && + keeporig = (!rangeTableEntry_used((Node *) sub_action->jointree, + rt_index, 0)) && (rangeTableEntry_used(info->rule_qual, rt_index, 0) || - rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0)); + rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0)); newjointree = adjustJoinTreeList(parsetree, !keeporig, rt_index); sub_action->jointree->fromlist = nconc(newjointree, sub_action->jointree->fromlist); @@ -154,17 +155,17 @@ gatherRewriteMeta(Query *parsetree, parsetree->hasSubLinks = TRUE; /* - * Event Qualification forces copying of parsetree and - * splitting into two queries one w/rule_qual, one w/NOT - * rule_qual. Also add user query qual onto rule action + * Event Qualification forces copying of parsetree and splitting into + * two queries one w/rule_qual, one w/NOT rule_qual. Also add user + * query qual onto rule action */ AddQual(sub_action, info->rule_qual); AddQual(sub_action, parsetree->jointree->quals); /* - * Rewrite new.attribute w/ right hand side of target-list - * entry for appropriate field name in insert/update. + * Rewrite new.attribute w/ right hand side of target-list entry for + * appropriate field name in insert/update. * * KLUGE ALERT: since ResolveNew returns a mutated copy, we can't just * apply it to sub_action; we have to remember to update the sublink @@ -207,7 +208,7 @@ adjustJoinTreeList(Query *parsetree, bool removert, int rt_index) { RangeTblRef *rtr = lfirst(jjt); - if (IsA(rtr, RangeTblRef) && rtr->rtindex == rt_index) + if (IsA(rtr, RangeTblRef) &&rtr->rtindex == rt_index) { newjointree = lremove(rtr, newjointree); break; @@ -278,7 +279,7 @@ ApplyRetrieveRule(Query *parsetree, elog(ERROR, "ApplyRetrieveRule: expected just one rule action"); if (rule->qual != NULL) elog(ERROR, "ApplyRetrieveRule: can't handle qualified ON SELECT rule"); - if (! relation_level) + if (!relation_level) elog(ERROR, "ApplyRetrieveRule: can't handle per-attribute ON SELECT rule"); /* @@ -290,8 +291,8 @@ ApplyRetrieveRule(Query *parsetree, rule_action = fireRIRrules(rule_action); /* - * VIEWs are really easy --- just plug the view query in as a subselect, - * replacing the relation's original RTE. + * VIEWs are really easy --- just plug the view query in as a + * subselect, replacing the relation's original RTE. */ rte = rt_fetch(rt_index, parsetree->rtable); @@ -317,6 +318,7 @@ ApplyRetrieveRule(Query *parsetree, */ if (intMember(rt_index, parsetree->rowMarks)) { + /* * Remove the view from the list of rels that will actually be * marked FOR UPDATE by the executor. It will still be access- @@ -399,6 +401,7 @@ fireRIRonSubLink(Node *node, void *context) sub->subselect = (Node *) fireRIRrules((Query *) (sub->subselect)); /* Fall through to process lefthand args of SubLink */ } + /* * Do NOT recurse into Query nodes, because fireRIRrules already * processed subselects of subselects for us. @@ -462,17 +465,17 @@ fireRIRrules(Query *parsetree) continue; /* - * This may well be the first access to the relation during - * the current statement (it will be, if this Query was extracted - * from a rule or somehow got here other than via the parser). - * Therefore, grab the appropriate lock type for the relation, - * and do not release it until end of transaction. This protects - * the rewriter and planner against schema changes mid-query. + * This may well be the first access to the relation during the + * current statement (it will be, if this Query was extracted from + * a rule or somehow got here other than via the parser). + * Therefore, grab the appropriate lock type for the relation, and + * do not release it until end of transaction. This protects the + * rewriter and planner against schema changes mid-query. * - * If the relation is the query's result relation, then RewriteQuery() - * already got the right lock on it, so we need no additional lock. - * Otherwise, check to see if the relation is accessed FOR UPDATE - * or not. + * If the relation is the query's result relation, then + * RewriteQuery() already got the right lock on it, so we need no + * additional lock. Otherwise, check to see if the relation is + * accessed FOR UPDATE or not. */ if (rt_index == parsetree->resultRelation) lockmode = NoLock; @@ -534,14 +537,14 @@ fireRIRrules(Query *parsetree) */ if (parsetree->hasSubLinks) query_tree_walker(parsetree, fireRIRonSubLink, NULL, - false /* already handled the ones in rtable */); + false /* already handled the ones in rtable */ ); /* - * If the query was marked having aggregates, check if this is - * still true after rewriting. Ditto for sublinks. Note there - * should be no aggs in the qual at this point. (Does this code - * still do anything useful? The view-becomes-subselect-in-FROM - * approach doesn't look like it could remove aggs or sublinks...) + * If the query was marked having aggregates, check if this is still + * true after rewriting. Ditto for sublinks. Note there should be no + * aggs in the qual at this point. (Does this code still do anything + * useful? The view-becomes-subselect-in-FROM approach doesn't look + * like it could remove aggs or sublinks...) */ if (parsetree->hasAggs) { @@ -551,9 +554,7 @@ fireRIRrules(Query *parsetree) elog(ERROR, "fireRIRrules: failed to remove aggs from qual"); } if (parsetree->hasSubLinks) - { parsetree->hasSubLinks = checkExprHasSubLink((Node *) parsetree); - } return parsetree; } @@ -594,7 +595,7 @@ orderRules(List *locks) * This is used to generate suitable "else clauses" for conditional INSTEAD * rules. * - * The rule_qual may contain references to OLD or NEW. OLD references are + * The rule_qual may contain references to OLD or NEW. OLD references are * replaced by references to the specified rt_index (the relation that the * rule applies to). NEW references are only possible for INSERT and UPDATE * queries on the relation itself, and so they should be replaced by copies @@ -769,12 +770,12 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) rt_entry = rt_fetch(result_relation, parsetree->rtable); /* - * This may well be the first access to the result relation during - * the current statement (it will be, if this Query was extracted - * from a rule or somehow got here other than via the parser). - * Therefore, grab the appropriate lock type for a result relation, - * and do not release it until end of transaction. This protects the - * rewriter and planner against schema changes mid-query. + * This may well be the first access to the result relation during the + * current statement (it will be, if this Query was extracted from a + * rule or somehow got here other than via the parser). Therefore, + * grab the appropriate lock type for a result relation, and do not + * release it until end of transaction. This protects the rewriter + * and planner against schema changes mid-query. */ rt_entry_relation = heap_openr(rt_entry->relname, RowExclusiveLock); @@ -793,7 +794,7 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) qual_products); } - heap_close(rt_entry_relation, NoLock); /* keep lock! */ + heap_close(rt_entry_relation, NoLock); /* keep lock! */ return product_queries; } @@ -912,7 +913,7 @@ QueryRewrite(Query *parsetree) */ foreach(l, querylist) { - Query *query = (Query *) lfirst(l); + Query *query = (Query *) lfirst(l); query = fireRIRrules(query); diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index d83dafa3c6..663b67708e 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.55 2001/01/27 01:44:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.56 2001/03/22 03:59:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,9 +43,10 @@ static bool checkExprHasSubLink_walker(Node *node, void *context); bool checkExprHasAggs(Node *node) { + /* - * If a Query is passed, examine it --- but we will not recurse - * into sub-Queries. + * If a Query is passed, examine it --- but we will not recurse into + * sub-Queries. */ if (node && IsA(node, Query)) return query_tree_walker((Query *) node, checkExprHasAggs_walker, @@ -73,9 +74,10 @@ checkExprHasAggs_walker(Node *node, void *context) bool checkExprHasSubLink(Node *node) { + /* - * If a Query is passed, examine it --- but we will not recurse - * into sub-Queries. + * If a Query is passed, examine it --- but we will not recurse into + * sub-Queries. */ if (node && IsA(node, Query)) return query_tree_walker((Query *) node, checkExprHasSubLink_walker, @@ -101,7 +103,7 @@ checkExprHasSubLink_walker(Node *node, void *context) * * Find all Var nodes in the given tree with varlevelsup == sublevels_up, * and increment their varno fields (rangetable indexes) by 'offset'. - * The varnoold fields are adjusted similarly. Also, RangeTblRef nodes + * The varnoold fields are adjusted similarly. Also, RangeTblRef nodes * in join trees and setOp trees are adjusted. * * NOTE: although this has the form of a walker, we cheat and modify the @@ -133,7 +135,7 @@ OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context) } if (IsA(node, RangeTblRef)) { - RangeTblRef *rtr = (RangeTblRef *) node; + RangeTblRef *rtr = (RangeTblRef *) node; if (context->sublevels_up == 0) rtr->rtindex += context->offset; @@ -170,24 +172,22 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) */ if (node && IsA(node, Query)) { - Query *qry = (Query *) node; - List *l; + Query *qry = (Query *) node; + List *l; /* - * If we are starting at a Query, and sublevels_up is zero, then we - * must also fix rangetable indexes in the Query itself --- namely - * resultRelation and rowMarks entries. sublevels_up cannot be zero - * when recursing into a subquery, so there's no need to have the - * same logic inside OffsetVarNodes_walker. + * If we are starting at a Query, and sublevels_up is zero, then + * we must also fix rangetable indexes in the Query itself --- + * namely resultRelation and rowMarks entries. sublevels_up + * cannot be zero when recursing into a subquery, so there's no + * need to have the same logic inside OffsetVarNodes_walker. */ if (sublevels_up == 0) { if (qry->resultRelation) qry->resultRelation += offset; foreach(l, qry->rowMarks) - { lfirsti(l) += offset; - } } query_tree_walker(qry, OffsetVarNodes_walker, (void *) &context, true); @@ -235,7 +235,7 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context) } if (IsA(node, RangeTblRef)) { - RangeTblRef *rtr = (RangeTblRef *) node; + RangeTblRef *rtr = (RangeTblRef *) node; if (context->sublevels_up == 0 && rtr->rtindex == context->rt_index) @@ -274,15 +274,15 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) */ if (node && IsA(node, Query)) { - Query *qry = (Query *) node; - List *l; + Query *qry = (Query *) node; + List *l; /* - * If we are starting at a Query, and sublevels_up is zero, then we - * must also fix rangetable indexes in the Query itself --- namely - * resultRelation and rowMarks entries. sublevels_up cannot be zero - * when recursing into a subquery, so there's no need to have the - * same logic inside ChangeVarNodes_walker. + * If we are starting at a Query, and sublevels_up is zero, then + * we must also fix rangetable indexes in the Query itself --- + * namely resultRelation and rowMarks entries. sublevels_up + * cannot be zero when recursing into a subquery, so there's no + * need to have the same logic inside ChangeVarNodes_walker. */ if (sublevels_up == 0) { @@ -541,11 +541,12 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr) return parsetree; if (parsetree->commandType != CMD_INSERT) return parsetree; + /* - * Currently, this is ONLY applied to rule-action queries, and so - * we expect to find the *OLD* and *NEW* placeholder entries in the - * given query. If they're not there, it must be an INSERT/SELECT - * in which they've been pushed down to the SELECT. + * Currently, this is ONLY applied to rule-action queries, and so we + * expect to find the *OLD* and *NEW* placeholder entries in the given + * query. If they're not there, it must be an INSERT/SELECT in which + * they've been pushed down to the SELECT. */ if (length(parsetree->rtable) >= 2 && strcmp(rt_fetch(PRS2_OLD_VARNO, parsetree->rtable)->eref->relname, @@ -560,17 +561,17 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr) Assert(IsA(rtr, RangeTblRef)); selectrte = rt_fetch(rtr->rtindex, parsetree->rtable); selectquery = selectrte->subquery; - if (! (selectquery && IsA(selectquery, Query) && - selectquery->commandType == CMD_SELECT)) + if (!(selectquery && IsA(selectquery, Query) && + selectquery->commandType == CMD_SELECT)) elog(ERROR, "getInsertSelectQuery: expected to find SELECT subquery"); if (length(selectquery->rtable) >= 2 && - strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->relname, - "*OLD*") == 0 && - strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->relname, - "*NEW*") == 0) + strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->relname, + "*OLD*") == 0 && + strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->relname, + "*NEW*") == 0) { if (subquery_ptr) - *subquery_ptr = & (selectrte->subquery); + *subquery_ptr = &(selectrte->subquery); return selectquery; } elog(ERROR, "getInsertSelectQuery: can't find rule placeholders"); @@ -591,11 +592,12 @@ AddQual(Query *parsetree, Node *qual) if (parsetree->commandType == CMD_UTILITY) { + /* * Noplace to put the qual on a utility statement. * - * For now, we expect utility stmt to be a NOTIFY, so give a - * specific error message for that case. + * For now, we expect utility stmt to be a NOTIFY, so give a specific + * error message for that case. */ if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt)) elog(ERROR, "Conditional NOTIFY is not implemented"); @@ -632,11 +634,12 @@ AddHavingQual(Query *parsetree, Node *havingQual) if (parsetree->commandType == CMD_UTILITY) { + /* * Noplace to put the qual on a utility statement. * - * For now, we expect utility stmt to be a NOTIFY, so give a - * specific error message for that case. + * For now, we expect utility stmt to be a NOTIFY, so give a specific + * error message for that case. */ if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt)) elog(ERROR, "Conditional NOTIFY is not implemented"); @@ -839,8 +842,8 @@ ResolveNew(Node *node, int target_varno, int sublevels_up, /* * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, go straight to query_tree_mutator to make sure that - * sublevels_up doesn't get incremented prematurely. + * if it's a Query, go straight to query_tree_mutator to make sure + * that sublevels_up doesn't get incremented prematurely. */ if (node && IsA(node, Query)) { @@ -876,11 +879,11 @@ typedef struct int *modified; int *badsql; int sublevels_up; -} HandleRIRAttributeRule_context; +} HandleRIRAttributeRule_context; static Node * HandleRIRAttributeRule_mutator(Node *node, - HandleRIRAttributeRule_context *context) + HandleRIRAttributeRule_context * context) { if (node == NULL) return NULL; @@ -988,4 +991,4 @@ HandleRIRAttributeRule(Query *parsetree, (void *) &context, true); } -#endif /* NOT_USED */ +#endif /* NOT_USED */ diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index 7063b505b9..15e3434721 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.43 2001/01/24 19:43:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.44 2001/03/22 03:59:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ RewriteGetRuleEventRel(char *rulename) 0, 0, 0); if (!HeapTupleIsValid(htup)) elog(ERROR, "Rule or view \"%s\" not found", - ((strncmp(rulename, "_RET", 4) == 0) ? (rulename + 4) : rulename)); + ((strncmp(rulename, "_RET", 4) == 0) ? (rulename + 4) : rulename)); eventrel = ((Form_pg_rewrite) GETSTRUCT(htup))->ev_class; ReleaseSysCache(htup); @@ -102,15 +102,15 @@ RemoveRewriteRule(char *ruleName) /* * We had better grab AccessExclusiveLock so that we know no other - * rule additions/deletions are going on for this relation. Else - * we cannot set relhasrules correctly. Besides, we don't want to - * be changing the ruleset while queries are executing on the rel. + * rule additions/deletions are going on for this relation. Else we + * cannot set relhasrules correctly. Besides, we don't want to be + * changing the ruleset while queries are executing on the rel. */ event_relation = heap_open(eventRelationOid, AccessExclusiveLock); /* do not allow the removal of a view's SELECT rule */ if (event_relation->rd_rel->relkind == RELKIND_VIEW && - ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_type == '1' ) + ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_type == '1') elog(ERROR, "Cannot remove a view's SELECT rule"); hasMoreRules = event_relation->rd_rules != NULL && @@ -133,10 +133,9 @@ RemoveRewriteRule(char *ruleName) /* * Set pg_class 'relhasrules' field correctly for event relation. * - * Important side effect: an SI notice is broadcast to force all - * backends (including me!) to update relcache entries with the - * new rule set. Therefore, must do this even if relhasrules is - * still true! + * Important side effect: an SI notice is broadcast to force all backends + * (including me!) to update relcache entries with the new rule set. + * Therefore, must do this even if relhasrules is still true! */ SetRelationRuleStatus(eventRelationOid, hasMoreRules, false); diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index 0a171bb897..7578acbced 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.47 2001/01/24 19:43:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.48 2001/03/22 03:59:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,8 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules, Relation idescs[Num_pg_class_indices]; /* - * Find the tuple to update in pg_class, using syscache for the lookup. + * Find the tuple to update in pg_class, using syscache for the + * lookup. */ relationRelation = heap_openr(RelationRelationName, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, |