88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.109 2008/12/15 21:35:31 tgl Exp $
11+ * $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.110 2008/12/16 00:56:12 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2929#include "rewrite/rewriteManip.h"
3030#include "rewrite/rewriteSupport.h"
3131#include "utils/acl.h"
32+ #include "utils/builtins.h"
3233#include "utils/lsyscache.h"
3334#include "utils/rel.h"
3435
@@ -263,7 +264,7 @@ checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc)
263264Form_pg_attribute newattr = newdesc -> attrs [i ];
264265Form_pg_attribute oldattr = olddesc -> attrs [i ];
265266
266- /* XXX not right, but we don't support DROP COL on view anyway */
267+ /* XXXmsg not right, but we don't support DROP COL on view anyway */
267268if (newattr -> attisdropped != oldattr -> attisdropped )
268269ereport (ERROR ,
269270(errcode (ERRCODE_INVALID_TABLE_DEFINITION ),
@@ -272,15 +273,20 @@ checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc)
272273if (strcmp (NameStr (newattr -> attname ),NameStr (oldattr -> attname ))!= 0 )
273274ereport (ERROR ,
274275(errcode (ERRCODE_INVALID_TABLE_DEFINITION ),
275- errmsg ("cannot change name of view column \"%s\"" ,
276- NameStr (oldattr -> attname ))));
276+ errmsg ("cannot change name of view column \"%s\" to \"%s\"" ,
277+ NameStr (oldattr -> attname ),
278+ NameStr (newattr -> attname ))));
277279/* XXX would it be safe to allow atttypmod to change? Not sure */
278280if (newattr -> atttypid != oldattr -> atttypid ||
279281newattr -> atttypmod != oldattr -> atttypmod )
280282ereport (ERROR ,
281283(errcode (ERRCODE_INVALID_TABLE_DEFINITION ),
282- errmsg ("cannot change data type of view column \"%s\"" ,
283- NameStr (oldattr -> attname ))));
284+ errmsg ("cannot change data type of view column \"%s\" from %s to %s" ,
285+ NameStr (oldattr -> attname ),
286+ format_type_with_typemod (oldattr -> atttypid ,
287+ oldattr -> atttypmod ),
288+ format_type_with_typemod (newattr -> atttypid ,
289+ newattr -> atttypmod ))));
284290/* We can ignore the remaining attributes of an attribute... */
285291}
286292