MCPcopy Create free account
hub / github.com/apache/cloudberry / transformAExprNullIf

Function transformAExprNullIf

src/backend/parser/parse_expr.c:1055–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1053}
1054
1055static Node *
1056transformAExprNullIf(ParseState *pstate, A_Expr *a)
1057{
1058 Node *lexpr = transformExprRecurse(pstate, a->lexpr);
1059 Node *rexpr = transformExprRecurse(pstate, a->rexpr);
1060 OpExpr *result;
1061
1062 result = (OpExpr *) make_op(pstate,
1063 a->name,
1064 lexpr,
1065 rexpr,
1066 pstate->p_last_srf,
1067 a->location);
1068
1069 /*
1070 * The comparison operator itself should yield boolean ...
1071 */
1072 if (result->opresulttype != BOOLOID)
1073 ereport(ERROR,
1074 (errcode(ERRCODE_DATATYPE_MISMATCH),
1075 errmsg("NULLIF requires = operator to yield boolean"),
1076 parser_errposition(pstate, a->location)));
1077 if (result->opretset)
1078 ereport(ERROR,
1079 (errcode(ERRCODE_DATATYPE_MISMATCH),
1080 /* translator: %s is name of a SQL construct, eg NULLIF */
1081 errmsg("%s must not return a set", "NULLIF"),
1082 parser_errposition(pstate, a->location)));
1083
1084 /*
1085 * ... but the NullIfExpr will yield the first operand's type.
1086 */
1087 result->opresulttype = exprType((Node *) linitial(result->args));
1088
1089 /*
1090 * We rely on NullIfExpr and OpExpr being the same struct
1091 */
1092 NodeSetTag(result, T_NullIfExpr);
1093
1094 return (Node *) result;
1095}
1096
1097static Node *
1098transformAExprIn(ParseState *pstate, A_Expr *a)

Callers 1

transformExprRecurseFunction · 0.85

Calls 6

transformExprRecurseFunction · 0.85
make_opFunction · 0.85
parser_errpositionFunction · 0.85
exprTypeFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected