{
if (node == NULL)
return NULL;
- if (IsA(node, Param))
+ switch (nodeTag(node))
+ {
+ case T_Param:
{
Param *param = (Param *) node;
/* Not replaceable, so just copy the Param (no need to recurse) */
return (Node *) copyObject(param);
}
- if (IsA(node, FuncExpr))
+ case T_FuncExpr:
{
FuncExpr *expr = (FuncExpr *) node;
List *args;
newexpr->location = expr->location;
return (Node *) newexpr;
}
- if (IsA(node, OpExpr))
+ case T_OpExpr:
{
OpExpr *expr = (OpExpr *) node;
List *args;
newexpr->location = expr->location;
return (Node *) newexpr;
}
- if (IsA(node, DistinctExpr))
+ case T_DistinctExpr:
{
DistinctExpr *expr = (DistinctExpr *) node;
List *args;
newexpr->location = expr->location;
return (Node *) newexpr;
}
- if (IsA(node, BoolExpr))
+ case T_BoolExpr:
{
BoolExpr *expr = (BoolExpr *) node;
(int) expr->boolop);
break;
}
+ break;
}
- if (IsA(node, SubPlan) ||
- IsA(node, AlternativeSubPlan))
- {
+ case T_SubPlan:
+ case T_AlternativeSubPlan:
/*
* Return a SubPlan unchanged --- too late to do anything with it.
*
* never be invoked after SubPlan creation.
*/
return node;
- }
- if (IsA(node, RelabelType))
+ case T_RelabelType:
{
/*
* If we can simplify the input to a constant, then we don't need the
return (Node *) newrelabel;
}
}
- if (IsA(node, CoerceViaIO))
+ case T_CoerceViaIO:
{
CoerceViaIO *expr = (CoerceViaIO *) node;
Expr *arg;
newexpr->location = expr->location;
return (Node *) newexpr;
}
- if (IsA(node, ArrayCoerceExpr))
+ case T_ArrayCoerceExpr:
{
ArrayCoerceExpr *expr = (ArrayCoerceExpr *) node;
Expr *arg;
/* Else we must return the partially-simplified node */
return (Node *) newexpr;
}
- if (IsA(node, CollateExpr))
+ case T_CollateExpr:
{
/*
* If we can simplify the input to a constant, then we don't need the
return (Node *) relabel;
}
}
- if (IsA(node, CaseExpr))
+ case T_CaseExpr:
{
/*----------
* CASE expressions can be simplified if there are constant
newcase->location = caseexpr->location;
return (Node *) newcase;
}
- if (IsA(node, CaseTestExpr))
+ case T_CaseTestExpr:
{
/*
* If we know a constant test value for the current CASE construct,
else
return copyObject(node);
}
- if (IsA(node, ArrayExpr))
+ case T_ArrayExpr:
{
ArrayExpr *arrayexpr = (ArrayExpr *) node;
ArrayExpr *newarray;
return (Node *) newarray;
}
- if (IsA(node, CoalesceExpr))
+ case T_CoalesceExpr:
{
CoalesceExpr *coalesceexpr = (CoalesceExpr *) node;
CoalesceExpr *newcoalesce;
newcoalesce->location = coalesceexpr->location;
return (Node *) newcoalesce;
}
- if (IsA(node, FieldSelect))
+ case T_FieldSelect:
{
/*
* We can optimize field selection from a whole-row Var into a simple
newfselect->resultcollid = fselect->resultcollid;
return (Node *) newfselect;
}
- if (IsA(node, NullTest))
+ case T_NullTest:
{
NullTest *ntest = (NullTest *) node;
NullTest *newntest;
newntest->argisrow = ntest->argisrow;
return (Node *) newntest;
}
- if (IsA(node, BooleanTest))
+ case T_BooleanTest:
{
BooleanTest *btest = (BooleanTest *) node;
BooleanTest *newbtest;
newbtest->booltesttype = btest->booltesttype;
return (Node *) newbtest;
}
- if (IsA(node, PlaceHolderVar) &&context->estimate)
- {
+ case T_PlaceHolderVar:
/*
* In estimation mode, just strip the PlaceHolderVar node altogether;
* this amounts to estimating that the contained value won't be forced
* behavior (ie, simplify the expression but leave the PlaceHolderVar
* node intact).
*/
- PlaceHolderVar *phv = (PlaceHolderVar *) node;
+ if (context->estimate)
+ {
+ PlaceHolderVar *phv = (PlaceHolderVar *) node;
- return eval_const_expressions_mutator((Node *) phv->phexpr,
- context);
+ return eval_const_expressions_mutator((Node *) phv->phexpr,
+ context);
+ }
+ break;
+ default:
+ break;
}
/*