1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

Ye-old pgindent run. Same 4-space tabs.

This commit is contained in:
Bruce Momjian
2000-04-12 17:17:23 +00:00
parent db4518729d
commit 52f77df613
434 changed files with 24799 additions and 21246 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.27 2000/01/26 05:56:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.28 2000/04/12 17:15:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -34,15 +34,16 @@
* XXX this should be unified with attribute_used()
*/
typedef struct {
typedef struct
{
int varno;
int attnum;
int sublevels_up;
} thisLockWasTriggered_context;
static bool
thisLockWasTriggered_walker (Node *node,
thisLockWasTriggered_context *context)
thisLockWasTriggered_walker(Node *node,
thisLockWasTriggered_context *context)
{
if (node == NULL)
return false;
@ -58,9 +59,10 @@ thisLockWasTriggered_walker (Node *node,
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -69,7 +71,7 @@ thisLockWasTriggered_walker (Node *node,
context->sublevels_up++;
if (thisLockWasTriggered_walker((Node *) (sub->subselect), context))
{
context->sublevels_up--; /* not really necessary */
context->sublevels_up--; /* not really necessary */
return true;
}
context->sublevels_up--;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.43 2000/02/26 06:36:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.44 2000/04/12 17:15:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -40,7 +40,8 @@ quoteString(StringInfo buf, char *source)
appendStringInfoChar(buf, '\'');
for (current = source; *current; current++)
{
char ch = *current;
char ch = *current;
if (ch == '\'' || ch == '\\')
{
appendStringInfoChar(buf, '\\');
@ -297,7 +298,7 @@ DefineQueryRewrite(RuleStmt *stmt)
rule = event_relation->rd_rules->rules[i];
if (rule->event == CMD_SELECT)
elog(ERROR, "%s is already a view",
RelationGetRelationName(event_relation));
RelationGetRelationName(event_relation));
}
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.70 2000/04/04 02:30:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.71 2000/04/12 17:15:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -55,19 +55,19 @@ static RewriteInfo *gatherRewriteMeta(Query *parsetree,
bool *instead_flag);
static bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up);
static bool attribute_used(Node *node, int rt_index, int attno,
int sublevels_up);
int sublevels_up);
static bool modifyAggrefChangeVarnodes(Node *node, int rt_index, int new_index,
int sublevels_up, int new_sublevels_up);
int sublevels_up, int new_sublevels_up);
static Node *modifyAggrefDropQual(Node *node, Node *targetNode);
static SubLink *modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree);
static Node *modifyAggrefQual(Node *node, Query *parsetree);
static Query *fireRIRrules(Query *parsetree);
static Query *Except_Intersect_Rewrite(Query *parsetree);
static void check_targetlists_are_compatible(List *prev_target,
List *current_target);
List *current_target);
static void create_intersect_list(Node *ptr, List **intersect_list);
static Node *intersect_tree_analyze(Node *tree, Node *first_select,
Node *parsetree);
Node *parsetree);
/*
* gatherRewriteMeta -
@ -148,14 +148,15 @@ gatherRewriteMeta(Query *parsetree,
* referenced somewhere in var nodes of the query.
*/
typedef struct {
typedef struct
{
int rt_index;
int sublevels_up;
} rangeTableEntry_used_context;
static bool
rangeTableEntry_used_walker (Node *node,
rangeTableEntry_used_context *context)
rangeTableEntry_used_walker(Node *node,
rangeTableEntry_used_context *context)
{
if (node == NULL)
return false;
@ -170,9 +171,10 @@ rangeTableEntry_used_walker (Node *node,
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -218,15 +220,16 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
* somewhere in the query
*/
typedef struct {
typedef struct
{
int rt_index;
int attno;
int sublevels_up;
} attribute_used_context;
static bool
attribute_used_walker (Node *node,
attribute_used_context *context)
attribute_used_walker(Node *node,
attribute_used_context *context)
{
if (node == NULL)
return false;
@ -242,9 +245,10 @@ attribute_used_walker (Node *node,
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -296,11 +300,12 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up)
* not having the option to adjust the vars' varlevelsup.
*
* NOTE: although this has the form of a walker, we cheat and modify the
* Var nodes in-place. The given expression tree should have been copied
* Var nodes in-place. The given expression tree should have been copied
* earlier to ensure that no unwanted side-effects occur!
*/
typedef struct {
typedef struct
{
int rt_index;
int new_index;
int sublevels_up;
@ -309,7 +314,7 @@ typedef struct {
static bool
modifyAggrefChangeVarnodes_walker(Node *node,
modifyAggrefChangeVarnodes_context *context)
modifyAggrefChangeVarnodes_context *context)
{
if (node == NULL)
return false;
@ -328,9 +333,10 @@ modifyAggrefChangeVarnodes_walker(Node *node,
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -386,7 +392,7 @@ modifyAggrefChangeVarnodes(Node *node, int rt_index, int new_index,
* targetNode is an Aggref node somewhere within the given expression tree.
* Find the boolean operator that's presumably somewhere above it, and replace
* that whole operator expression with a constant TRUE. (This is NOT really
* quite the right thing, but it handles simple cases. This whole set of
* quite the right thing, but it handles simple cases. This whole set of
* Aggref-in-qual routines needs to be thrown away when we can do subselects
* in FROM.)
*
@ -439,8 +445,10 @@ static SubLink *
modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
{
List *aggVarNos;
/* rte points to old structure: */
RangeTblEntry *rte;
/* these point to newly-created structures: */
Query *subquery;
SubLink *sublink;
@ -463,7 +471,7 @@ modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
tle = makeNode(TargetEntry);
tle->resdom = resdom;
tle->expr = copyObject(aggref); /* make a modifiable copy! */
tle->expr = copyObject(aggref); /* make a modifiable copy! */
subquery = makeNode(Query);
@ -488,10 +496,11 @@ modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
subquery->targetList = lcons(tle, NIL);
subquery->qual = modifyAggrefDropQual((Node *) parsetree->qual,
(Node *) aggref);
/*
* If there are still aggs in the subselect's qual, give up.
* Recursing would be a bad idea --- we'd likely produce an
* infinite recursion. This whole technique is a crock, really...
* If there are still aggs in the subselect's qual, give up. Recursing
* would be a bad idea --- we'd likely produce an infinite recursion.
* This whole technique is a crock, really...
*/
if (checkExprHasAggs(subquery->qual))
elog(ERROR, "Cannot handle multiple aggregate functions in WHERE clause");
@ -504,7 +513,8 @@ modifyAggrefMakeSublink(Aggref *aggref, Query *parsetree)
/* Increment all varlevelsup fields in the new subquery */
IncrementVarSublevelsUp((Node *) subquery, 1, 0);
/* Replace references to the target table with correct local varno, 1.
/*
* Replace references to the target table with correct local varno, 1.
* Note that because of previous line, these references have
* varlevelsup = 1, which must be changed to 0.
*/
@ -537,11 +547,12 @@ modifyAggrefQual(Node *node, Query *parsetree)
parsetree->hasSubLinks = true;
return (Node *) sub;
}
/*
* Otherwise, fall through and copy the expr normally.
*
* We do NOT recurse into subselects in this routine. It's sufficient
* to get rid of aggregates that are in the qual expression proper.
* We do NOT recurse into subselects in this routine. It's sufficient to
* get rid of aggregates that are in the qual expression proper.
*/
return expression_tree_mutator(node, modifyAggrefQual,
(void *) parsetree);
@ -585,12 +596,13 @@ make_null(Oid type)
* Replace Vars matching a given RT index with copies of TL expressions.
*/
typedef struct {
int rt_index;
int sublevels_up;
RangeTblEntry *rte;
List *tlist;
int *modified;
typedef struct
{
int rt_index;
int sublevels_up;
RangeTblEntry *rte;
List *tlist;
int *modified;
} apply_RIR_view_context;
static Node *
@ -633,14 +645,15 @@ apply_RIR_view_mutator(Node *node,
}
/* otherwise fall through to copy the var normally */
}
/*
* Since expression_tree_mutator won't touch subselects, we have to
* handle them specially.
*/
if (IsA(node, SubLink))
{
SubLink *sublink = (SubLink *) node;
SubLink *newnode;
SubLink *sublink = (SubLink *) node;
SubLink *newnode;
FLATCOPY(newnode, sublink, SubLink);
MUTATE(newnode->lefthand, sublink->lefthand, List *,
@ -653,8 +666,8 @@ apply_RIR_view_mutator(Node *node,
}
if (IsA(node, Query))
{
Query *query = (Query *) node;
Query *newnode;
Query *query = (Query *) node;
Query *newnode;
FLATCOPY(newnode, query, Query);
MUTATE(newnode->targetList, query->targetList, List *,
@ -673,7 +686,7 @@ static Node *
apply_RIR_view(Node *node, int rt_index, RangeTblEntry *rte, List *tlist,
int *modified, int sublevels_up)
{
apply_RIR_view_context context;
apply_RIR_view_context context;
context.rt_index = rt_index;
context.sublevels_up = sublevels_up;
@ -718,18 +731,20 @@ ApplyRetrieveRule(Query *parsetree,
nothing = TRUE;
rtable = copyObject(parsetree->rtable);
rt_length = length(rtable); /* original length, not counting rule */
rt_length = length(rtable); /* original length, not counting rule */
addedrtable = copyObject(rule_action->rtable);
/* If the original rel wasn't in the join set, none of its spawn is.
/*
* If the original rel wasn't in the join set, none of its spawn is.
* If it was, then leave the spawn's flags as they are.
*/
if (! relWasInJoinSet)
if (!relWasInJoinSet)
{
foreach(l, addedrtable)
{
RangeTblEntry *rte = lfirst(l);
rte->inJoinSet = false;
}
}
@ -789,7 +804,7 @@ ApplyRetrieveRule(Query *parsetree,
if (relation_level)
{
RangeTblEntry *rte = rt_fetch(rt_index, rtable);
RangeTblEntry *rte = rt_fetch(rt_index, rtable);
parsetree = (Query *) apply_RIR_view((Node *) parsetree,
rt_index, rte,
@ -824,7 +839,7 @@ ApplyRetrieveRule(Query *parsetree,
* Apply fireRIRrules() to each subselect found in the given tree.
*
* NOTE: although this has the form of a walker, we cheat and modify the
* SubLink nodes in-place. It is caller's responsibility to ensure that
* SubLink nodes in-place. It is caller's responsibility to ensure that
* no unwanted side-effects occur!
*/
static bool
@ -883,8 +898,9 @@ fireRIRrules(Query *parsetree)
int i;
List *l;
/* don't try to convert this into a foreach loop, because
* rtable list can get changed each time through...
/*
* don't try to convert this into a foreach loop, because rtable list
* can get changed each time through...
*/
rt_index = 0;
while (rt_index < length(parsetree->rtable))
@ -894,13 +910,13 @@ fireRIRrules(Query *parsetree)
rte = rt_fetch(rt_index, parsetree->rtable);
/*
* If the table is not one named in the original FROM clause
* then it must be referenced in the query, or we ignore it.
* This prevents infinite expansion loop due to new rtable
* entries inserted by expansion of a rule.
* If the table is not one named in the original FROM clause then
* it must be referenced in the query, or we ignore it. This
* prevents infinite expansion loop due to new rtable entries
* inserted by expansion of a rule.
*/
if (! rte->inFromCl && rt_index != parsetree->resultRelation &&
! rangeTableEntry_used((Node *) parsetree, rt_index, 0))
if (!rte->inFromCl && rt_index != parsetree->resultRelation &&
!rangeTableEntry_used((Node *) parsetree, rt_index, 0))
{
/* Make sure the planner ignores it too... */
rte->inJoinSet = false;
@ -915,7 +931,8 @@ fireRIRrules(Query *parsetree)
continue;
}
relWasInJoinSet = rte->inJoinSet; /* save before possibly clearing */
relWasInJoinSet = rte->inJoinSet; /* save before possibly
* clearing */
/*
* Collect the RIR rules that we must apply
@ -930,16 +947,18 @@ fireRIRrules(Query *parsetree)
if (rule->attrno > 0)
{
/* per-attr rule; do we need it? */
if (! attribute_used((Node *) parsetree,
rt_index,
rule->attrno, 0))
if (!attribute_used((Node *) parsetree,
rt_index,
rule->attrno, 0))
continue;
}
else
{
/* Rel-wide ON SELECT DO INSTEAD means this is a view.
* Remove the view from the planner's join target set,
* or we'll get no rows out because view itself is empty!
/*
* Rel-wide ON SELECT DO INSTEAD means this is a view.
* Remove the view from the planner's join target set, or
* we'll get no rows out because view itself is empty!
*/
if (rule->isInstead)
rte->inJoinSet = false;
@ -1448,7 +1467,7 @@ BasicQueryRewrite(Query *parsetree)
/*
* If the query was marked having aggregates, check if this is
* still true after rewriting. Ditto for sublinks. Note there
* still true after rewriting. Ditto for sublinks. Note there
* should be no aggs in the qual at this point.
*/
if (query->hasAggs)
@ -1663,6 +1682,7 @@ Except_Intersect_Rewrite(Query *parsetree)
*/
if (parsetree->commandType == CMD_INSERT)
{
/*
* The result relation ( = the one to insert into) has to be
* attached to the rtable list of the new top node
@ -1825,7 +1845,8 @@ Except_Intersect_Rewrite(Query *parsetree)
/*
* Also prepare the list of Opers that must be used for the
* comparisons (they depend on the specific datatypes involved!)
* comparisons (they depend on the specific datatypes
* involved!)
*/
left_expr = n->lefthand;
right_expr = ((Query *) (n->subselect))->targetList;
@ -1848,8 +1869,8 @@ Except_Intersect_Rewrite(Query *parsetree)
if (opform->oprresult != BOOLOID)
elog(ERROR, "parser: '%s' must return 'bool' to be used with quantified predicate subquery", op);
newop = makeOper(oprid(optup),/* opno */
InvalidOid, /* opid */
newop = makeOper(oprid(optup), /* opno */
InvalidOid, /* opid */
opform->oprresult,
0,
NULL);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.45 2000/03/16 03:23:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.46 2000/04/12 17:15:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -52,7 +52,8 @@ checkExprHasAggs_walker(Node *node, void *context)
if (node == NULL)
return false;
if (IsA(node, Aggref))
return true; /* abort the tree traversal and return true */
return true; /* abort the tree traversal and return
* true */
return expression_tree_walker(node, checkExprHasAggs_walker, context);
}
@ -73,7 +74,8 @@ checkExprHasSubLink_walker(Node *node, void *context)
if (node == NULL)
return false;
if (IsA(node, SubLink))
return true; /* abort the tree traversal and return true */
return true; /* abort the tree traversal and return
* true */
return expression_tree_walker(node, checkExprHasSubLink_walker, context);
}
@ -86,11 +88,12 @@ checkExprHasSubLink_walker(Node *node, void *context)
* The varnoold fields are adjusted similarly.
*
* NOTE: although this has the form of a walker, we cheat and modify the
* Var nodes in-place. The given expression tree should have been copied
* Var nodes in-place. The given expression tree should have been copied
* earlier to ensure that no unwanted side-effects occur!
*/
typedef struct {
typedef struct
{
int offset;
int sublevels_up;
} OffsetVarNodes_context;
@ -113,9 +116,10 @@ OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context)
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -162,14 +166,15 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up)
*
* Find all Var nodes in the given tree belonging to a specific relation
* (identified by sublevels_up and rt_index), and change their varno fields
* to 'new_index'. The varnoold fields are changed too.
* to 'new_index'. The varnoold fields are changed too.
*
* NOTE: although this has the form of a walker, we cheat and modify the
* Var nodes in-place. The given expression tree should have been copied
* Var nodes in-place. The given expression tree should have been copied
* earlier to ensure that no unwanted side-effects occur!
*/
typedef struct {
typedef struct
{
int rt_index;
int new_index;
int sublevels_up;
@ -194,9 +199,10 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context)
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -253,11 +259,12 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
* to the expression's original query level or parents thereof.
*
* NOTE: although this has the form of a walker, we cheat and modify the
* Var nodes in-place. The given expression tree should have been copied
* Var nodes in-place. The given expression tree should have been copied
* earlier to ensure that no unwanted side-effects occur!
*/
typedef struct {
typedef struct
{
int delta_sublevels_up;
int min_sublevels_up;
} IncrementVarSublevelsUp_context;
@ -278,9 +285,10 @@ IncrementVarSublevelsUp_walker(Node *node,
}
if (IsA(node, SubLink))
{
/*
* Standard expression_tree_walker will not recurse into subselect,
* but here we must do so.
* Standard expression_tree_walker will not recurse into
* subselect, but here we must do so.
*/
SubLink *sub = (SubLink *) node;
@ -346,7 +354,8 @@ AddQual(Query *parsetree, Node *qual)
/*
* Make sure query is marked correctly if added qual has sublinks or
* aggregates (not sure it can ever have aggs, but sublinks definitely).
* aggregates (not sure it can ever have aggs, but sublinks
* definitely).
*/
parsetree->hasAggs |= checkExprHasAggs(copy);
parsetree->hasSubLinks |= checkExprHasSubLink(copy);
@ -376,7 +385,8 @@ AddHavingQual(Query *parsetree, Node *havingQual)
/*
* Make sure query is marked correctly if added qual has sublinks or
* aggregates (not sure it can ever have aggs, but sublinks definitely).
* aggregates (not sure it can ever have aggs, but sublinks
* definitely).
*/
parsetree->hasAggs |= checkExprHasAggs(copy);
parsetree->hasSubLinks |= checkExprHasSubLink(copy);
@ -396,6 +406,7 @@ AddNotHavingQual(Query *parsetree, Node *havingQual)
AddHavingQual(parsetree, notqual);
}
#endif
void
@ -435,7 +446,8 @@ AddGroupClause(Query *parsetree, List *group_by, List *tlist)
/* copy the groupclause's TLE from the old tlist */
tle = (TargetEntry *) copyObject(tle);
/* The ressortgroupref number in the old tlist might be already
/*
* The ressortgroupref number in the old tlist might be already
* taken in the new tlist, so force assignment of a new number.
*/
tle->resdom->ressortgroupref = 0;
@ -528,10 +540,11 @@ FindMatchingTLEntry(List *tlist, char *e_attname)
* entry with matching resno from targetlist, if there is one.
*/
typedef struct {
RewriteInfo *info;
List *targetlist;
int sublevels_up;
typedef struct
{
RewriteInfo *info;
List *targetlist;
int sublevels_up;
} ResolveNew_context;
static Node *
@ -579,14 +592,15 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context)
}
/* otherwise fall through to copy the var normally */
}
/*
* Since expression_tree_mutator won't touch subselects, we have to
* handle them specially.
*/
if (IsA(node, SubLink))
{
SubLink *sublink = (SubLink *) node;
SubLink *newnode;
SubLink *sublink = (SubLink *) node;
SubLink *newnode;
FLATCOPY(newnode, sublink, SubLink);
MUTATE(newnode->lefthand, sublink->lefthand, List *,
@ -599,8 +613,8 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context)
}
if (IsA(node, Query))
{
Query *query = (Query *) node;
Query *newnode;
Query *query = (Query *) node;
Query *newnode;
/*
* XXX original code for ResolveNew only recursed into qual field
@ -624,7 +638,7 @@ static Node *
ResolveNew(Node *node, RewriteInfo *info, List *targetlist,
int sublevels_up)
{
ResolveNew_context context;
ResolveNew_context context;
context.info = info;
context.targetlist = targetlist;
@ -637,13 +651,13 @@ void
FixNew(RewriteInfo *info, Query *parsetree)
{
info->rule_action->targetList = (List *)
ResolveNew((Node *) info->rule_action->targetList,
info, parsetree->targetList, 0);
ResolveNew((Node *) info->rule_action->targetList,
info, parsetree->targetList, 0);
info->rule_action->qual = ResolveNew(info->rule_action->qual,
info, parsetree->targetList, 0);
/* XXX original code didn't fix havingQual; presumably an oversight? */
info->rule_action->havingQual = ResolveNew(info->rule_action->havingQual,
info, parsetree->targetList, 0);
info, parsetree->targetList, 0);
}
/*
@ -656,14 +670,15 @@ FixNew(RewriteInfo *info, Query *parsetree)
* XXX Why is this not unified with apply_RIR_view()?
*/
typedef struct {
List *rtable;
List *targetlist;
int rt_index;
int attr_num;
int *modified;
int *badsql;
int sublevels_up;
typedef struct
{
List *rtable;
List *targetlist;
int rt_index;
int attr_num;
int *modified;
int *badsql;
int sublevels_up;
} HandleRIRAttributeRule_context;
static Node *
@ -691,7 +706,7 @@ HandleRIRAttributeRule_mutator(Node *node,
}
else
{
char *name_to_look_for;
char *name_to_look_for;
name_to_look_for = get_attname(getrelid(this_varno,
context->rtable),
@ -707,7 +722,11 @@ HandleRIRAttributeRule_mutator(Node *node,
return make_null(var->vartype);
/* Make a copy of the tlist item to return */
n = copyObject(n);
/* Adjust varlevelsup if tlist item is from higher query */
/*
* Adjust varlevelsup if tlist item is from higher
* query
*/
if (this_varlevelsup > 0)
IncrementVarSublevelsUp(n, this_varlevelsup, 0);
return n;
@ -716,14 +735,15 @@ HandleRIRAttributeRule_mutator(Node *node,
}
/* otherwise fall through to copy the var normally */
}
/*
* Since expression_tree_mutator won't touch subselects, we have to
* handle them specially.
*/
if (IsA(node, SubLink))
{
SubLink *sublink = (SubLink *) node;
SubLink *newnode;
SubLink *sublink = (SubLink *) node;
SubLink *newnode;
FLATCOPY(newnode, sublink, SubLink);
MUTATE(newnode->lefthand, sublink->lefthand, List *,
@ -736,12 +756,12 @@ HandleRIRAttributeRule_mutator(Node *node,
}
if (IsA(node, Query))
{
Query *query = (Query *) node;
Query *newnode;
Query *query = (Query *) node;
Query *newnode;
/*
* XXX original code for HandleRIRAttributeRule only recursed into
* qual field of subquery. I'm assuming that was an oversight ...
* qual field of subquery. I'm assuming that was an oversight ...
*/
FLATCOPY(newnode, query, Query);
@ -766,7 +786,7 @@ HandleRIRAttributeRule(Query *parsetree,
int *modified,
int *badsql)
{
HandleRIRAttributeRule_context context;
HandleRIRAttributeRule_context context;
context.rtable = rtable;
context.targetlist = targetlist;
@ -776,7 +796,7 @@ HandleRIRAttributeRule(Query *parsetree,
context.badsql = badsql;
context.sublevels_up = 0;
parsetree->targetList = (List *)
parsetree->targetList = (List *)
HandleRIRAttributeRule_mutator((Node *) parsetree->targetList,
&context);
parsetree->qual = HandleRIRAttributeRule_mutator(parsetree->qual,

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.35 2000/01/26 05:56:50 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.36 2000/04/12 17:15:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -125,8 +125,8 @@ RemoveRewriteRule(char *ruleName)
/*
* Delete any comments associated with this rule
*
*/
*/
DeleteComments(ruleId);
/*
@ -168,13 +168,14 @@ RelationRemoveRules(Oid relid)
scanDesc = heap_beginscan(RewriteRelation,
0, SnapshotNow, 1, &scanKeyData);
while (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0))) {
while (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0)))
{
/*** Delete any comments associated with this relation ***/
/*** Delete any comments associated with this relation ***/
DeleteComments(tuple->t_data->t_oid);
heap_delete(RewriteRelation, &tuple->t_self, NULL);
DeleteComments(tuple->t_data->t_oid);
heap_delete(RewriteRelation, &tuple->t_self, NULL);
}