*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.248 2003/07/21 01:59:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.249 2003/07/29 17:21:20 tgl Exp $
*
*
* INTERFACE ROUTINES
* in the expression. (Even though we plan to reject vars, it's more
* user-friendly to give the correct error message than "unknown var".)
*
- * If atttypid is not InvalidOid, check that the expression is coercible
- * to the specified type. atttypmod is needed in this case, and attname
- * is used in the error message if any.
+ * If atttypid is not InvalidOid, coerce the expression to the specified
+ * type (and typmod atttypmod). attname is only needed in this case:
+ * it is used in the error message, if any.
*/
Node *
cookDefault(ParseState *pstate,
errmsg("cannot use aggregate in DEFAULT clause")));
/*
- * Check that it will be possible to coerce the expression to the
- * column's type. We store the expression without coercion, however,
- * to avoid premature coercion in cases like
- *
- * CREATE TABLE tbl (fld timestamp DEFAULT 'now');
- *
- * NB: this should match the code in rewrite/rewriteHandler.c that will
- * actually do the coercion, to ensure we don't accept an unusable
- * default expression.
+ * Coerce the expression to the correct type and typmod, if given. This
+ * should match the parser's processing of non-defaulted expressions ---
+ * see updateTargetListEntry().
*/
if (OidIsValid(atttypid))
{
Oid type_id = exprType(expr);
- if (coerce_to_target_type(pstate, expr, type_id,
- atttypid, atttypmod,
- COERCION_ASSIGNMENT,
- COERCE_IMPLICIT_CAST) == NULL)
+ expr = coerce_to_target_type(pstate, expr, type_id,
+ atttypid, atttypmod,
+ COERCION_ASSIGNMENT,
+ COERCE_IMPLICIT_CAST);
+ if (expr == NULL)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("column \"%s\" is of type %s"
errhint("You will need to rewrite or cast the expression.")));
}
- return (expr);
+ return expr;
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.124 2003/07/25 00:01:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.125 2003/07/29 17:21:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
return NULL; /* No default anywhere */
/*
- * Make sure the value is coerced to the target column type (might not
- * be right type yet if it's not a constant!) This should match the
- * parser's processing of non-defaulted expressions --- see
- * updateTargetListEntry().
+ * Make sure the value is coerced to the target column type; this will
+ * generally be true already, but there seem to be some corner cases
+ * involving domain defaults where it might not be true.
+ * This should match the parser's processing of non-defaulted expressions
+ * --- see updateTargetListEntry().
*/
exprtype = exprType(expr);
atttype, atttypmod,
COERCION_ASSIGNMENT,
COERCE_IMPLICIT_CAST);
- /*
- * This really shouldn't fail; should have checked the default's
- * type when it was created ...
- */
if (expr == NULL)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.202 2003/06/29 00:33:44 tgl Exp $
+ * $Id: catversion.h,v 1.203 2003/07/29 17:21:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200306281
+#define CATALOG_VERSION_NO 200307291
#endif