diff --git a/doc/src/sgml/ref/create_view.sgml b/doc/src/sgml/ref/create_view.sgml
index e7a7e9fae2..fcde4a0581 100644
*** a/doc/src/sgml/ref/create_view.sgml
--- b/doc/src/sgml/ref/create_view.sgml
***************
*** 41,47 **** CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW <replaceable class
     <command>CREATE OR REPLACE VIEW</command> is similar, but if a view
     of the same name already exists, it is replaced.  The new query must
     generate the same columns that were generated by the existing view query
!    (that is, the same column names in the same order and with the same data
     types), but it may add additional columns to the end of the list.  The
     calculations giving rise to the output columns may be completely different.
    </para>
--- 41,47 ----
     <command>CREATE OR REPLACE VIEW</command> is similar, but if a view
     of the same name already exists, it is replaced.  The new query must
     generate the same columns that were generated by the existing view query
!    (that is, the columns in the same order and with the same data
     types), but it may add additional columns to the end of the list.  The
     calculations giving rise to the output columns may be completely different.
    </para>
diff --git a/src/backend/commands/tablecindex 8d25d14772..0bdea166b6 100644
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 2910,2916 **** renameatt_check(Oid myrelid, Form_pg_class classform, bool recursing)
   *
   * Return value is the attribute number in the 'myrelid' relation.
   */
! static AttrNumber
  renameatt_internal(Oid myrelid,
  				   const char *oldattname,
  				   const char *newattname,
--- 2910,2916 ----
   *
   * Return value is the attribute number in the 'myrelid' relation.
   */
! AttrNumber
  renameatt_internal(Oid myrelid,
  				   const char *oldattname,
  				   const char *newattname,
diff --git a/src/backend/commands/view.index bea890f177..3708cee692 100644
*** a/src/backend/commands/view.c
--- b/src/backend/commands/view.c
***************
*** 109,114 **** DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace,
--- 109,115 ----
  		List	   *atcmds = NIL;
  		AlterTableCmd *atcmd;
  		ObjectAddress address;
+ 		int			i;
  
  		/* Relation is already locked, but we must build a relcache entry. */
  		rel = relation_open(viewOid, NoLock);
***************
*** 172,177 **** DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace,
--- 173,209 ----
  			CommandCounterIncrement();
  		}
  
+ 		/*
+ 		 * If attributes have been renamed, we must update pg_attribute
+ 		 * entries for them.
+ 		 *
+ 		 * Note that we must do this before updating the query for the view,
+ 		 * since the rules system requires that the correct view columns be in
+ 		 * place when defining the new rules.
+ 		 */
+ 		for (i = 0; i < rel->rd_att->natts; i++)
+ 		{
+ 			char	*newattname;
+ 			char	*oldattname;
+ 
+ 			newattname = NameStr(TupleDescAttr(descriptor, i)->attname);
+ 			oldattname = NameStr(TupleDescAttr(rel->rd_att, i)->attname);
+ 
+ 			if (strcmp(newattname, oldattname) != 0)
+ 			{
+ 				renameatt_internal(viewOid,
+ 								   oldattname,
+ 								   newattname,
+ 								   false,
+ 								   false,
+ 								   0,
+ 								   DROP_RESTRICT);
+ 
+ 				/* Make the new name of view column visible */
+ 				CommandCounterIncrement();
+ 			}
+ 		}
+ 
  		/*
  		 * Update the query for the view.
  		 *
***************
*** 272,283 **** checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc)
  					(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
  					 errmsg("cannot drop columns from view")));
  
- 		if (strcmp(NameStr(newattr->attname), NameStr(oldattr->attname)) != 0)
- 			ereport(ERROR,
- 					(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
- 					 errmsg("cannot change name of view column \"%s\" to \"%s\"",
- 							NameStr(oldattr->attname),
- 							NameStr(newattr->attname))));
  		/* XXX would it be safe to allow atttypmod to change?  Not sure */
  		if (newattr->atttypid != oldattr->atttypid ||
  			newattr->atttypmod != oldattr->atttypmod)
--- 304,309 ----
diff --git a/src/include/commands/index 9c25a805f2..c7d1f54e82 100644
*** a/src/include/commands/tablecmds.h
--- b/src/include/commands/tablecmds.h
***************
*** 60,65 **** extern void SetRelationHasSubclass(Oid relationId, bool relhassubclass);
--- 60,70 ----
  
  extern ObjectAddress renameatt(RenameStmt *stmt);
  
+ extern AttrNumber renameatt_internal(Oid myrelid, const char *oldattname,
+ 									 const char *newattname, bool recurse,
+ 									 bool recursing, int expected_parents,
+ 									 DropBehavior behavior);
+ 
  extern ObjectAddress RenameConstraint(RenameStmt *stmt);
  
  extern ObjectAddress RenameRelation(RenameStmt *stmt);
diff --git a/src/test/regress/expected/index 2fd36ca9a1..4a4fc95fd9 100644
*** a/src/test/regress/expected/create_view.out
--- b/src/test/regress/expected/create_view.out
***************
*** 63,74 **** ERROR:  cannot drop columns from view
  -- should fail
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT 1, * FROM viewtest_tbl;
! ERROR:  cannot change name of view column "a" to "?column?"
  -- should fail
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT a, b::numeric FROM viewtest_tbl;
  ERROR:  cannot change data type of view column "b" from integer to numeric
  -- should work
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT a, b, 0 AS c FROM viewtest_tbl;
  DROP VIEW viewtest;
--- 63,77 ----
  -- should fail
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT 1, * FROM viewtest_tbl;
! ERROR:  column "b" of relation "viewtest" already exists
  -- should fail
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT a, b::numeric FROM viewtest_tbl;
  ERROR:  cannot change data type of view column "b" from integer to numeric
  -- should work
+ CREATE OR REPLACE VIEW viewtest AS
+ 	SELECT a AS x, b AS y FROM viewtest_tbl;
+ -- should work
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT a, b, 0 AS c FROM viewtest_tbl;
  DROP VIEW viewtest;
diff --git a/src/test/regress/sql/create_view.sqindex 8c0f45cc52..7d89b5ee3a 100644
*** a/src/test/regress/sql/create_view.sql
--- b/src/test/regress/sql/create_view.sql
***************
*** 73,78 **** CREATE OR REPLACE VIEW viewtest AS
--- 73,82 ----
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT a, b::numeric FROM viewtest_tbl;
  
+ -- should work
+ CREATE OR REPLACE VIEW viewtest AS
+ 	SELECT a AS x, b AS y FROM viewtest_tbl;
+ 
  -- should work
  CREATE OR REPLACE VIEW viewtest AS
  	SELECT a, b, 0 AS c FROM viewtest_tbl;
