@@ -111,8 +111,7 @@ exprType(const Node *expr)
111
111
112
112
if (!qtree || !IsA (qtree , Query ))
113
113
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 ));
116
115
Assert (!tent -> resjunk );
117
116
type = exprType ((Node * ) tent -> expr );
118
117
if (sublink -> subLinkType == ARRAY_SUBLINK )
@@ -322,8 +321,7 @@ exprTypmod(const Node *expr)
322
321
323
322
if (!qtree || !IsA (qtree , Query ))
324
323
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 ));
327
325
Assert (!tent -> resjunk );
328
326
return exprTypmod ((Node * ) tent -> expr );
329
327
/* note we don't need to care if it's an array */
@@ -381,9 +379,8 @@ exprTypmod(const Node *expr)
381
379
return -1 ; /* no point in trying harder */
382
380
foreach (arg , cexpr -> args )
383
381
{
384
- CaseWhen * w = (CaseWhen * ) lfirst (arg );
382
+ CaseWhen * w = castNode (CaseWhen , lfirst (arg ) );
385
383
386
- Assert (IsA (w , CaseWhen ));
387
384
if (exprType ((Node * ) w -> result ) != casetype )
388
385
return -1 ;
389
386
if (exprTypmod ((Node * ) w -> result ) != typmod )
@@ -809,8 +806,7 @@ exprCollation(const Node *expr)
809
806
810
807
if (!qtree || !IsA (qtree , Query ))
811
808
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 ));
814
810
Assert (!tent -> resjunk );
815
811
coll = exprCollation ((Node * ) tent -> expr );
816
812
/* collation doesn't change if it's converted to array */
@@ -1052,8 +1048,7 @@ exprSetCollation(Node *expr, Oid collation)
1052
1048
1053
1049
if (!qtree || !IsA (qtree , Query ))
1054
1050
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 ));
1057
1052
Assert (!tent -> resjunk );
1058
1053
Assert (collation == exprCollation ((Node * ) tent -> expr ));
1059
1054
}
@@ -2050,9 +2045,8 @@ expression_tree_walker(Node *node,
2050
2045
/* we assume walker doesn't care about CaseWhens, either */
2051
2046
foreach (temp , caseexpr -> args )
2052
2047
{
2053
- CaseWhen * when = (CaseWhen * ) lfirst (temp );
2048
+ CaseWhen * when = castNode (CaseWhen , lfirst (temp ) );
2054
2049
2055
- Assert (IsA (when , CaseWhen ));
2056
2050
if (walker (when -> expr , context ))
2057
2051
return true;
2058
2052
if (walker (when -> result , context ))
@@ -3261,9 +3255,8 @@ raw_expression_tree_walker(Node *node,
3261
3255
/* we assume walker doesn't care about CaseWhens, either */
3262
3256
foreach (temp , caseexpr -> args )
3263
3257
{
3264
- CaseWhen * when = (CaseWhen * ) lfirst (temp );
3258
+ CaseWhen * when = castNode (CaseWhen , lfirst (temp ) );
3265
3259
3266
- Assert (IsA (when , CaseWhen ));
3267
3260
if (walker (when -> expr , context ))
3268
3261
return true;
3269
3262
if (walker (when -> result , context ))
@@ -3735,9 +3728,8 @@ planstate_walk_subplans(List *plans,
3735
3728
3736
3729
foreach (lc , plans )
3737
3730
{
3738
- SubPlanState * sps = (SubPlanState * ) lfirst (lc );
3731
+ SubPlanState * sps = castNode (SubPlanState , lfirst (lc ) );
3739
3732
3740
- Assert (IsA (sps , SubPlanState ));
3741
3733
if (walker (sps -> planstate , context ))
3742
3734
return true;
3743
3735
}
0 commit comments