diff options
Diffstat (limited to 'src/backend/nodes/nodeFuncs.c')
-rw-r--r-- | src/backend/nodes/nodeFuncs.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index c2f03b73f4a..71b24a079cd 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -111,8 +111,7 @@ exprType(const Node *expr) if (!qtree || !IsA(qtree, Query)) elog(ERROR, "cannot get type for untransformed sublink"); - tent = (TargetEntry *) linitial(qtree->targetList); - Assert(IsA(tent, TargetEntry)); + tent = castNode(TargetEntry, linitial(qtree->targetList)); Assert(!tent->resjunk); type = exprType((Node *) tent->expr); if (sublink->subLinkType == ARRAY_SUBLINK) @@ -322,8 +321,7 @@ exprTypmod(const Node *expr) if (!qtree || !IsA(qtree, Query)) elog(ERROR, "cannot get type for untransformed sublink"); - tent = (TargetEntry *) linitial(qtree->targetList); - Assert(IsA(tent, TargetEntry)); + tent = castNode(TargetEntry, linitial(qtree->targetList)); Assert(!tent->resjunk); return exprTypmod((Node *) tent->expr); /* note we don't need to care if it's an array */ @@ -381,9 +379,8 @@ exprTypmod(const Node *expr) return -1; /* no point in trying harder */ foreach(arg, cexpr->args) { - CaseWhen *w = (CaseWhen *) lfirst(arg); + CaseWhen *w = castNode(CaseWhen, lfirst(arg)); - Assert(IsA(w, CaseWhen)); if (exprType((Node *) w->result) != casetype) return -1; if (exprTypmod((Node *) w->result) != typmod) @@ -809,8 +806,7 @@ exprCollation(const Node *expr) if (!qtree || !IsA(qtree, Query)) elog(ERROR, "cannot get collation for untransformed sublink"); - tent = (TargetEntry *) linitial(qtree->targetList); - Assert(IsA(tent, TargetEntry)); + tent = castNode(TargetEntry, linitial(qtree->targetList)); Assert(!tent->resjunk); coll = exprCollation((Node *) tent->expr); /* collation doesn't change if it's converted to array */ @@ -1052,8 +1048,7 @@ exprSetCollation(Node *expr, Oid collation) if (!qtree || !IsA(qtree, Query)) elog(ERROR, "cannot set collation for untransformed sublink"); - tent = (TargetEntry *) linitial(qtree->targetList); - Assert(IsA(tent, TargetEntry)); + tent = castNode(TargetEntry, linitial(qtree->targetList)); Assert(!tent->resjunk); Assert(collation == exprCollation((Node *) tent->expr)); } @@ -2050,9 +2045,8 @@ expression_tree_walker(Node *node, /* we assume walker doesn't care about CaseWhens, either */ foreach(temp, caseexpr->args) { - CaseWhen *when = (CaseWhen *) lfirst(temp); + CaseWhen *when = castNode(CaseWhen, lfirst(temp)); - Assert(IsA(when, CaseWhen)); if (walker(when->expr, context)) return true; if (walker(when->result, context)) @@ -3261,9 +3255,8 @@ raw_expression_tree_walker(Node *node, /* we assume walker doesn't care about CaseWhens, either */ foreach(temp, caseexpr->args) { - CaseWhen *when = (CaseWhen *) lfirst(temp); + CaseWhen *when = castNode(CaseWhen, lfirst(temp)); - Assert(IsA(when, CaseWhen)); if (walker(when->expr, context)) return true; if (walker(when->result, context)) @@ -3735,9 +3728,8 @@ planstate_walk_subplans(List *plans, foreach(lc, plans) { - SubPlanState *sps = (SubPlanState *) lfirst(lc); + SubPlanState *sps = castNode(SubPlanState, lfirst(lc)); - Assert(IsA(sps, SubPlanState)); if (walker(sps->planstate, context)) return true; } |