diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-20 21:32:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-20 21:32:16 +0000 |
commit | 57b30e8e226014c8d06bae0158e0c7fc679f700b (patch) | |
tree | 172a3052e6c88922d63726bacd092afac6bf053c /src/backend/executor | |
parent | bd8e071482e3c33876295aae5523fe57ce35025b (diff) | |
download | postgresql-57b30e8e226014c8d06bae0158e0c7fc679f700b.tar.gz postgresql-57b30e8e226014c8d06bae0158e0c7fc679f700b.zip |
Create a new expression node type RelabelType, which exists solely to
represent the result of a binary-compatible type coercion. At runtime
it just evaluates its argument --- but during type resolution, exprType
will pick up the output type of the RelabelType node instead of the type
of the argument. This solves some longstanding problems with dropped
type coercions, an example being 'select now()::abstime::int4' which
used to produce date-formatted output, not an integer, because the
coercion to int4 was dropped on the floor.
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execQual.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 91dbde63419..a319e2c2b37 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.67 2000/01/26 05:56:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.68 2000/02/20 21:32:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1176,7 +1176,7 @@ ExecEvalExpr(Node *expression, bool *isNull, bool *isDone) { - Datum retDatum = 0; + Datum retDatum; *isNull = false; @@ -1200,36 +1200,33 @@ ExecEvalExpr(Node *expression, switch (nodeTag(expression)) { case T_Var: - retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull); + retDatum = ExecEvalVar((Var *) expression, econtext, isNull); break; case T_Const: { Const *con = (Const *) expression; - if (con->constisnull) - *isNull = true; retDatum = con->constvalue; + *isNull = con->constisnull; break; } case T_Param: - retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull); + retDatum = ExecEvalParam((Param *) expression, econtext, isNull); break; case T_Iter: - retDatum = (Datum) ExecEvalIter((Iter *) expression, - econtext, - isNull, - isDone); + retDatum = ExecEvalIter((Iter *) expression, + econtext, + isNull, + isDone); break; case T_Aggref: - retDatum = (Datum) ExecEvalAggref((Aggref *) expression, - econtext, - isNull); + retDatum = ExecEvalAggref((Aggref *) expression, econtext, isNull); break; case T_ArrayRef: - retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression, - econtext, - isNull, - isDone); + retDatum = ExecEvalArrayRef((ArrayRef *) expression, + econtext, + isNull, + isDone); break; case T_Expr: { @@ -1238,37 +1235,48 @@ ExecEvalExpr(Node *expression, switch (expr->opType) { case OP_EXPR: - retDatum = (Datum) ExecEvalOper(expr, econtext, isNull); + retDatum = ExecEvalOper(expr, econtext, isNull); break; case FUNC_EXPR: - retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone); + retDatum = ExecEvalFunc(expr, econtext, + isNull, isDone); break; case OR_EXPR: - retDatum = (Datum) ExecEvalOr(expr, econtext, isNull); + retDatum = ExecEvalOr(expr, econtext, isNull); break; case AND_EXPR: - retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull); + retDatum = ExecEvalAnd(expr, econtext, isNull); break; case NOT_EXPR: - retDatum = (Datum) ExecEvalNot(expr, econtext, isNull); + retDatum = ExecEvalNot(expr, econtext, isNull); break; case SUBPLAN_EXPR: - retDatum = (Datum) ExecSubPlan((SubPlan *) expr->oper, - expr->args, econtext, - isNull); + retDatum = ExecSubPlan((SubPlan *) expr->oper, + expr->args, econtext, + isNull); break; default: - elog(ERROR, "ExecEvalExpr: unknown expression type %d", expr->opType); + elog(ERROR, "ExecEvalExpr: unknown expression type %d", + expr->opType); + retDatum = 0; /* keep compiler quiet */ break; } break; } + case T_RelabelType: + retDatum = ExecEvalExpr(((RelabelType *) expression)->arg, + econtext, + isNull, + isDone); + break; case T_CaseExpr: - retDatum = (Datum) ExecEvalCase((CaseExpr *) expression, econtext, isNull); + retDatum = ExecEvalCase((CaseExpr *) expression, econtext, isNull); break; default: - elog(ERROR, "ExecEvalExpr: unknown expression type %d", nodeTag(expression)); + elog(ERROR, "ExecEvalExpr: unknown expression type %d", + nodeTag(expression)); + retDatum = 0; /* keep compiler quiet */ break; } |