From 488c6dd1708a2c4a9e9f307001f28c05c48651bd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 15 May 2012 12:12:40 -0400 Subject: 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. --- src/backend/commands/tablecmds.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/backend/commands/tablecmds.c') 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 -- cgit v1.2.3