aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-03-11 15:26:43 -0400
committerRobert Haas <rhaas@postgresql.org>2015-03-11 15:26:43 -0400
commitbc93ac12c2544b6b3a68b6cb0282e0828fa14a34 (patch)
treec55d425c5973276495a1300d0c9f77f91de10566 /src/backend/parser/parse_relation.c
parentc6b3c939b7e0f1d35f4ed4996e71420a993810d2 (diff)
downloadpostgresql-bc93ac12c2544b6b3a68b6cb0282e0828fa14a34.tar.gz
postgresql-bc93ac12c2544b6b3a68b6cb0282e0828fa14a34.zip
Require non-NULL pstate for all addRangeTableEntryFor* functions.
Per discussion, it's better to have a consistent coding rule here. Michael Paquier, per a node from Greg Stark referencing an old post from Tom Lane.
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 80daeb9dc4a..ca560ccee1b 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -1245,6 +1245,8 @@ addRangeTableEntryForRelation(ParseState *pstate,
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);
@@ -1276,8 +1278,7 @@ addRangeTableEntryForRelation(ParseState *pstate,
* 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;
}
@@ -1302,6 +1303,8 @@ addRangeTableEntryForSubquery(ParseState *pstate,
int varattno;
ListCell *tlistitem;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_SUBQUERY;
rte->relid = InvalidOid;
rte->subquery = subquery;
@@ -1354,8 +1357,7 @@ addRangeTableEntryForSubquery(ParseState *pstate,
* 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;
}
@@ -1391,6 +1393,8 @@ addRangeTableEntryForFunction(ParseState *pstate,
int natts,
totalatts;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_FUNCTION;
rte->relid = InvalidOid;
rte->subquery = NULL;
@@ -1608,8 +1612,7 @@ addRangeTableEntryForFunction(ParseState *pstate,
* 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;
}
@@ -1633,6 +1636,8 @@ addRangeTableEntryForValues(ParseState *pstate,
int numaliases;
int numcolumns;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_VALUES;
rte->relid = InvalidOid;
rte->subquery = NULL;
@@ -1680,8 +1685,7 @@ addRangeTableEntryForValues(ParseState *pstate,
* 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;
}
@@ -1703,6 +1707,8 @@ addRangeTableEntryForJoin(ParseState *pstate,
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.
@@ -1748,8 +1754,7 @@ addRangeTableEntryForJoin(ParseState *pstate,
* 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;
}
@@ -1774,6 +1779,8 @@ addRangeTableEntryForCTE(ParseState *pstate,
int varattno;
ListCell *lc;
+ Assert(pstate != NULL);
+
rte->rtekind = RTE_CTE;
rte->ctename = cte->ctename;
rte->ctelevelsup = levelsup;
@@ -1848,8 +1855,7 @@ addRangeTableEntryForCTE(ParseState *pstate,
* 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;
}