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

Use the new castNode() macro in a number of places.

This is far from a pervasive conversion, but it's a good starting
point.

Author: Peter Eisentraut, with some minor changes by me
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/c5d387d9-3440-f5e0-f9d4-71d53b9fbe52@2ndquadrant.com
This commit is contained in:
Andres Freund
2017-01-26 16:47:03 -08:00
parent 5bcab11142
commit 9ba8a9ce45
32 changed files with 77 additions and 131 deletions

View File

@@ -2382,9 +2382,8 @@ JumbleRangeTable(pgssJumbleState *jstate, List *rtable)
foreach(lc, rtable)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
RangeTblEntry *rte = castNode(RangeTblEntry, lfirst(lc));
Assert(IsA(rte, RangeTblEntry));
APP_JUMB(rte->rtekind);
switch (rte->rtekind)
{
@@ -2570,7 +2569,7 @@ JumbleExpr(pgssJumbleState *jstate, Node *node)
APP_JUMB(sublink->subLinkType);
APP_JUMB(sublink->subLinkId);
JumbleExpr(jstate, (Node *) sublink->testexpr);
JumbleQuery(jstate, (Query *) sublink->subselect);
JumbleQuery(jstate, castNode(Query, sublink->subselect));
}
break;
case T_FieldSelect:
@@ -2636,9 +2635,8 @@ JumbleExpr(pgssJumbleState *jstate, Node *node)
JumbleExpr(jstate, (Node *) caseexpr->arg);
foreach(temp, caseexpr->args)
{
CaseWhen *when = (CaseWhen *) lfirst(temp);
CaseWhen *when = castNode(CaseWhen, lfirst(temp));
Assert(IsA(when, CaseWhen));
JumbleExpr(jstate, (Node *) when->expr);
JumbleExpr(jstate, (Node *) when->result);
}
@@ -2850,7 +2848,7 @@ JumbleExpr(pgssJumbleState *jstate, Node *node)
/* we store the string name because RTE_CTE RTEs need it */
APP_JUMB_STRING(cte->ctename);
JumbleQuery(jstate, (Query *) cte->ctequery);
JumbleQuery(jstate, castNode(Query, cte->ctequery));
}
break;
case T_SetOperationStmt:

View File

@@ -1315,10 +1315,7 @@ deparseExplicitTargetList(List *tlist, List **retrieved_attrs,
foreach(lc, tlist)
{
TargetEntry *tle = (TargetEntry *) lfirst(lc);
/* Extract expression if TargetEntry node */
Assert(IsA(tle, TargetEntry));
TargetEntry *tle = castNode(TargetEntry, lfirst(lc));
if (i > 0)
appendStringInfoString(buf, ", ");

View File

@@ -1159,9 +1159,7 @@ postgresGetForeignPlan(PlannerInfo *root,
*/
foreach(lc, scan_clauses)
{
RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
Assert(IsA(rinfo, RestrictInfo));
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
/* Ignore any pseudoconstants, they're dealt with elsewhere */
if (rinfo->pseudoconstant)
@@ -4958,14 +4956,12 @@ conversion_error_callback(void *arg)
{
/* error occurred in a scan against a foreign join */
ForeignScanState *fsstate = errpos->fsstate;
ForeignScan *fsplan = (ForeignScan *) fsstate->ss.ps.plan;
ForeignScan *fsplan = castNode(ForeignScan, fsstate->ss.ps.plan);
EState *estate = fsstate->ss.ps.state;
TargetEntry *tle;
Assert(IsA(fsplan, ForeignScan));
tle = (TargetEntry *) list_nth(fsplan->fdw_scan_tlist,
errpos->cur_attno - 1);
Assert(IsA(tle, TargetEntry));
tle = castNode(TargetEntry, list_nth(fsplan->fdw_scan_tlist,
errpos->cur_attno - 1));
/*
* Target list can have Vars and expressions. For Vars, we can get