@@ -111,8 +111,7 @@ exprType(const Node *expr)
111111
112112 if (!qtree || !IsA (qtree , Query ))
113113 elog (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 ));
116115 Assert (!tent -> resjunk );
117116 type = exprType ((Node * ) tent -> expr );
118117 if (sublink -> subLinkType == ARRAY_SUBLINK )
@@ -322,8 +321,7 @@ exprTypmod(const Node *expr)
322321
323322 if (!qtree || !IsA (qtree , Query ))
324323 elog (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 ));
327325 Assert (!tent -> resjunk );
328326 return 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)
381379 return -1 ; /* no point in trying harder */
382380 foreach (arg , cexpr -> args )
383381 {
384- CaseWhen * w = (CaseWhen * ) lfirst (arg );
382+ CaseWhen * w = castNode (CaseWhen , lfirst (arg ) );
385383
386- Assert (IsA (w , CaseWhen ));
387384 if (exprType ((Node * ) w -> result ) != casetype )
388385 return -1 ;
389386 if (exprTypmod ((Node * ) w -> result ) != typmod )
@@ -809,8 +806,7 @@ exprCollation(const Node *expr)
809806
810807 if (!qtree || !IsA (qtree , Query ))
811808 elog (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 ));
814810 Assert (!tent -> resjunk );
815811 coll = 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
10531049 if (!qtree || !IsA (qtree , Query ))
10541050 elog (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 ));
10571052 Assert (!tent -> resjunk );
10581053 Assert (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 */
20512046 foreach (temp , caseexpr -> args )
20522047 {
2053- CaseWhen * when = (CaseWhen * ) lfirst (temp );
2048+ CaseWhen * when = castNode (CaseWhen , lfirst (temp ) );
20542049
2055- Assert (IsA (when , CaseWhen ));
20562050 if (walker (when -> expr , context ))
20572051 return true;
20582052 if (walker (when -> result , context ))
@@ -3261,9 +3255,8 @@ raw_expression_tree_walker(Node *node,
32613255 /* we assume walker doesn't care about CaseWhens, either */
32623256 foreach (temp , caseexpr -> args )
32633257 {
3264- CaseWhen * when = (CaseWhen * ) lfirst (temp );
3258+ CaseWhen * when = castNode (CaseWhen , lfirst (temp ) );
32653259
3266- Assert (IsA (when , CaseWhen ));
32673260 if (walker (when -> expr , context ))
32683261 return true;
32693262 if (walker (when -> result , context ))
@@ -3735,9 +3728,8 @@ planstate_walk_subplans(List *plans,
37353728
37363729 foreach (lc , plans )
37373730 {
3738- SubPlanState * sps = (SubPlanState * ) lfirst (lc );
3731+ SubPlanState * sps = castNode (SubPlanState , lfirst (lc ) );
37393732
3740- Assert (IsA (sps , SubPlanState ));
37413733 if (walker (sps -> planstate , context ))
37423734 return true;
37433735 }
0 commit comments