List *new_rt;
RangeTblEntry *rt_entry1,
*rt_entry2;
+ ParseState *pstate;
/*
* Make a copy of the given parsetree. It's not so much that we don't
*/
viewParse = (Query *) copyObject(viewParse);
+ /* Create a dummy ParseState for addRangeTableEntryForRelation */
+ pstate = make_parsestate(NULL);
+
/* need to open the rel for addRangeTableEntryForRelation */
viewRel = relation_open(viewOid, AccessShareLock);
* Create the 2 new range table entries and form the new range table...
* OLD first, then NEW....
*/
- rt_entry1 = addRangeTableEntryForRelation(NULL, viewRel,
+ rt_entry1 = addRangeTableEntryForRelation(pstate, viewRel,
makeAlias("old", NIL),
false, false);
- rt_entry2 = addRangeTableEntryForRelation(NULL, viewRel,
+ rt_entry2 = addRangeTableEntryForRelation(pstate, viewRel,
makeAlias("new", NIL),
false, false);
/* Must override addRangeTableEntry's default access-check flags */
RangeTblRef *rtr;
List *subquery_vars;
Node *quals;
+ ParseState *pstate;
Assert(sublink->subLinkType == ANY_SUBLINK);
if (contain_volatile_functions(sublink->testexpr))
return NULL;
+ /* Create a dummy ParseState for addRangeTableEntryForSubquery */
+ pstate = make_parsestate(NULL);
+
/*
* Okay, pull up the sub-select into upper range table.
*
* below). Therefore this is a lot easier than what pull_up_subqueries has
* to go through.
*/
- rte = addRangeTableEntryForSubquery(NULL,
+ rte = addRangeTableEntryForSubquery(pstate,
subselect,
makeAlias("ANY_subquery", NIL),
false,
RangeTblEntry *rte = makeNode(RangeTblEntry);
char *refname = alias ? alias->aliasname : RelationGetRelationName(rel);
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_RELATION;
rte->alias = alias;
rte->relid = RelationGetRelid(rel);
* Add completed RTE to pstate's range table list, but not to join list
* nor namespace --- caller must do that if appropriate.
*/
- if (pstate != NULL)
- pstate->p_rtable = lappend(pstate->p_rtable, rte);
+ pstate->p_rtable = lappend(pstate->p_rtable, rte);
return rte;
}
int varattno;
ListCell *tlistitem;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_SUBQUERY;
rte->relid = InvalidOid;
rte->subquery = subquery;
* Add completed RTE to pstate's range table list, but not to join list
* nor namespace --- caller must do that if appropriate.
*/
- if (pstate != NULL)
- pstate->p_rtable = lappend(pstate->p_rtable, rte);
+ pstate->p_rtable = lappend(pstate->p_rtable, rte);
return rte;
}
int natts,
totalatts;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_FUNCTION;
rte->relid = InvalidOid;
rte->subquery = NULL;
* Add completed RTE to pstate's range table list, but not to join list
* nor namespace --- caller must do that if appropriate.
*/
- if (pstate != NULL)
- pstate->p_rtable = lappend(pstate->p_rtable, rte);
+ pstate->p_rtable = lappend(pstate->p_rtable, rte);
return rte;
}
int numaliases;
int numcolumns;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_VALUES;
rte->relid = InvalidOid;
rte->subquery = NULL;
* Add completed RTE to pstate's range table list, but not to join list
* nor namespace --- caller must do that if appropriate.
*/
- if (pstate != NULL)
- pstate->p_rtable = lappend(pstate->p_rtable, rte);
+ pstate->p_rtable = lappend(pstate->p_rtable, rte);
return rte;
}
Alias *eref;
int numaliases;
+ Assert(pstate != NULL);
+
/*
* Fail if join has too many columns --- we must be able to reference any
* of the columns with an AttrNumber.
* Add completed RTE to pstate's range table list, but not to join list
* nor namespace --- caller must do that if appropriate.
*/
- if (pstate != NULL)
- pstate->p_rtable = lappend(pstate->p_rtable, rte);
+ pstate->p_rtable = lappend(pstate->p_rtable, rte);
return rte;
}
int varattno;
ListCell *lc;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_CTE;
rte->ctename = cte->ctename;
rte->ctelevelsup = levelsup;
* Add completed RTE to pstate's range table list, but not to join list
* nor namespace --- caller must do that if appropriate.
*/
- if (pstate != NULL)
- pstate->p_rtable = lappend(pstate->p_rtable, rte);
+ pstate->p_rtable = lappend(pstate->p_rtable, rte);
return rte;
}