diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-05-15 12:12:40 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-05-16 07:28:25 -0400 |
commit | 488c6dd1708a2c4a9e9f307001f28c05c48651bd (patch) | |
tree | d16baea4aecc29adca676952b26ab1c88d7b6c3d /src/backend/commands/tablecmds.c | |
parent | 6593c5b5dc39b179b1b7a3c947df2596af3e70c9 (diff) | |
download | postgresql-488c6dd1708a2c4a9e9f307001f28c05c48651bd.tar.gz postgresql-488c6dd1708a2c4a9e9f307001f28c05c48651bd.zip |
Improve error message for ALTER COLUMN TYPE coercion failure.
Per recent discussion, the error message for this was actually a trifle
inaccurate, since it said "cannot be cast" which might be incorrect.
Adjust that wording, and add a HINT suggesting that a USING clause might
be needed.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index e23a3dab3cd..6148bd62da8 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -7315,8 +7315,9 @@ ATPrepAlterColumnType(List **wqueue, if (transform == NULL) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("column \"%s\" cannot be cast to type %s", - colName, format_type_be(targettype)))); + errmsg("column \"%s\" cannot be cast automatically to type %s", + colName, format_type_be(targettype)), + errhint("Specify a USING expression to perform the conversion."))); /* Fix collations after all else */ assign_expr_collations(pstate, transform); @@ -7482,7 +7483,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, if (defaultexpr == NULL) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("default for column \"%s\" cannot be cast to type %s", + errmsg("default for column \"%s\" cannot be cast automatically to type %s", colName, format_type_be(targettype)))); } else |