aboutsummaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rewriteHandler.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-07-29 17:21:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-07-29 17:21:27 +0000
commit5e3c09a11466acbe53a9bf75322a94c859d6c2f8 (patch)
treea8ba855335a90484be24537cd153d9205d15daca /src/backend/rewrite/rewriteHandler.c
parentf353f8e83bb447039b437cbaa3895d215da34f82 (diff)
downloadpostgresql-5e3c09a11466acbe53a9bf75322a94c859d6c2f8.tar.gz
postgresql-5e3c09a11466acbe53a9bf75322a94c859d6c2f8.zip
Coerce unknown-literal-constant default values to the column type during
CREATE TABLE (or ALTER TABLE SET DEFAULT), rather than postponing it to the time that the default is inserted into an INSERT command by the rewriter. This reverses an old decision that was intended to make the world safe for writing f1 timestamp default 'now' but in fact merely made the failure modes subtle rather than obvious. Per recent trouble report and followup discussion. initdb forced since there is a chance that stored default expressions will change.
Diffstat (limited to 'src/backend/rewrite/rewriteHandler.c')
-rw-r--r--src/backend/rewrite/rewriteHandler.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 34b6ceece9b..440e8ba7133 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -7,7 +7,7 @@
* 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 $
*
*-------------------------------------------------------------------------
*/
@@ -538,10 +538,11 @@ build_column_default(Relation rel, int attrno)
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);
@@ -550,10 +551,6 @@ build_column_default(Relation rel, int attrno)
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),