*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154.2.5 2007/02/02 00:04:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154.2.6 2007/03/06 22:45:41 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
#include "optimizer/var.h"
#include "parser/analyze.h"
#include "parser/parse_clause.h"
+#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "tcop/tcopprot.h"
#include "utils/acl.h"
newrelabel->arg = (Expr *) arg;
newrelabel->resulttype = relabel->resulttype;
newrelabel->resulttypmod = relabel->resulttypmod;
+ newrelabel->relabelformat = relabel->relabelformat;
return (Node *) newrelabel;
}
}
MemoryContextDelete(mycxt);
+ /*
+ * Since check_sql_fn_retval allows binary-compatibility cases, the
+ * expression we now have might return some type that's only binary
+ * compatible with the original expression result type. To avoid
+ * confusing matters, insert a RelabelType in such cases.
+ */
+ if (exprType(newexpr) != funcform->prorettype)
+ {
+ Assert(IsBinaryCoercible(exprType(newexpr), funcform->prorettype));
+ newexpr = (Node *) makeRelabelType((Expr *) newexpr,
+ funcform->prorettype,
+ -1,
+ COERCE_IMPLICIT_CAST);
+ }
+
/*
* Recursively try to simplify the modified expression. Here we must
* add the current function to the context list of active functions.