@@ -111,8 +111,7 @@ exprType(const Node *expr)
111111
112112if (!qtree || !IsA (qtree ,Query ))
113113elog (ERROR ,"cannot get type for untransformed sublink" );
114- tent = (TargetEntry * )linitial (qtree -> targetList );
115- Assert (IsA (tent ,TargetEntry ));
114+ tent = castNode (TargetEntry ,linitial (qtree -> targetList ));
116115Assert (!tent -> resjunk );
117116type = exprType ((Node * )tent -> expr );
118117if (sublink -> subLinkType == ARRAY_SUBLINK )
@@ -322,8 +321,7 @@ exprTypmod(const Node *expr)
322321
323322if (!qtree || !IsA (qtree ,Query ))
324323elog (ERROR ,"cannot get type for untransformed sublink" );
325- tent = (TargetEntry * )linitial (qtree -> targetList );
326- Assert (IsA (tent ,TargetEntry ));
324+ tent = castNode (TargetEntry ,linitial (qtree -> targetList ));
327325Assert (!tent -> resjunk );
328326return exprTypmod ((Node * )tent -> expr );
329327/* note we don't need to care if it's an array */
@@ -381,9 +379,8 @@ exprTypmod(const Node *expr)
381379return -1 ;/* no point in trying harder */
382380foreach (arg ,cexpr -> args )
383381{
384- CaseWhen * w = (CaseWhen * ) lfirst (arg );
382+ CaseWhen * w = castNode (CaseWhen , lfirst (arg ) );
385383
386- Assert (IsA (w ,CaseWhen ));
387384if (exprType ((Node * )w -> result )!= casetype )
388385return -1 ;
389386if (exprTypmod ((Node * )w -> result )!= typmod )
@@ -809,8 +806,7 @@ exprCollation(const Node *expr)
809806
810807if (!qtree || !IsA (qtree ,Query ))
811808elog (ERROR ,"cannot get collation for untransformed sublink" );
812- tent = (TargetEntry * )linitial (qtree -> targetList );
813- Assert (IsA (tent ,TargetEntry ));
809+ tent = castNode (TargetEntry ,linitial (qtree -> targetList ));
814810Assert (!tent -> resjunk );
815811coll = exprCollation ((Node * )tent -> expr );
816812/* collation doesn't change if it's converted to array */
@@ -1052,8 +1048,7 @@ exprSetCollation(Node *expr, Oid collation)
10521048
10531049if (!qtree || !IsA (qtree ,Query ))
10541050elog (ERROR ,"cannot set collation for untransformed sublink" );
1055- tent = (TargetEntry * )linitial (qtree -> targetList );
1056- Assert (IsA (tent ,TargetEntry ));
1051+ tent = castNode (TargetEntry ,linitial (qtree -> targetList ));
10571052Assert (!tent -> resjunk );
10581053Assert (collation == exprCollation ((Node * )tent -> expr ));
10591054}
@@ -2050,9 +2045,8 @@ expression_tree_walker(Node *node,
20502045/* we assume walker doesn't care about CaseWhens, either */
20512046foreach (temp ,caseexpr -> args )
20522047{
2053- CaseWhen * when = (CaseWhen * ) lfirst (temp );
2048+ CaseWhen * when = castNode (CaseWhen , lfirst (temp ) );
20542049
2055- Assert (IsA (when ,CaseWhen ));
20562050if (walker (when -> expr ,context ))
20572051return true;
20582052if (walker (when -> result ,context ))
@@ -3261,9 +3255,8 @@ raw_expression_tree_walker(Node *node,
32613255/* we assume walker doesn't care about CaseWhens, either */
32623256foreach (temp ,caseexpr -> args )
32633257{
3264- CaseWhen * when = (CaseWhen * ) lfirst (temp );
3258+ CaseWhen * when = castNode (CaseWhen , lfirst (temp ) );
32653259
3266- Assert (IsA (when ,CaseWhen ));
32673260if (walker (when -> expr ,context ))
32683261return true;
32693262if (walker (when -> result ,context ))
@@ -3735,9 +3728,8 @@ planstate_walk_subplans(List *plans,
37353728
37363729foreach (lc ,plans )
37373730{
3738- SubPlanState * sps = (SubPlanState * ) lfirst (lc );
3731+ SubPlanState * sps = castNode (SubPlanState , lfirst (lc ) );
37393732
3740- Assert (IsA (sps ,SubPlanState ));
37413733if (walker (sps -> planstate ,context ))
37423734return true;
37433735}