| 1053 | } |
| 1054 | |
| 1055 | static Node * |
| 1056 | transformAExprNullIf(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 | |
| 1097 | static Node * |
| 1098 | transformAExprIn(ParseState *pstate, A_Expr *a) |
no test coverage detected