Index: doc/src/sgml/reference.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/reference.sgml,v
retrieving revision 1.63
diff -c -r1.63 reference.sgml
*** doc/src/sgml/reference.sgml	26 Apr 2007 16:13:08 -0000	1.63
--- doc/src/sgml/reference.sgml	30 Jun 2007 00:14:47 -0000
***************
*** 53,58 ****
--- 53,59 ----
     &alterTrigger;
     &alterType;
     &alterUser;
+    &alterView;
     &analyze;
     &begin;
     &checkpoint;
Index: doc/src/sgml/ref/allfiles.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v
retrieving revision 1.70
diff -c -r1.70 allfiles.sgml
*** doc/src/sgml/ref/allfiles.sgml	26 Apr 2007 16:13:08 -0000	1.70
--- doc/src/sgml/ref/allfiles.sgml	30 Jun 2007 00:14:47 -0000
***************
*** 25,30 ****
--- 25,31 ----
  <!entity alterTrigger       system "alter_trigger.sgml">
  <!entity alterType          system "alter_type.sgml">
  <!entity alterUser          system "alter_user.sgml">
+ <!entity alterView          system "alter_view.sgml">
  <!entity analyze            system "analyze.sgml">
  <!entity begin              system "begin.sgml">
  <!entity checkpoint         system "checkpoint.sgml">
Index: doc/src/sgml/ref/alter_sequence.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/alter_sequence.sgml,v
retrieving revision 1.16
diff -c -r1.16 alter_sequence.sgml
*** doc/src/sgml/ref/alter_sequence.sgml	31 Jan 2007 23:26:02 -0000	1.16
--- doc/src/sgml/ref/alter_sequence.sgml	30 Jun 2007 00:14:47 -0000
***************
*** 29,34 ****
--- 29,35 ----
      [ RESTART [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
      [ OWNED BY { <replaceable class="parameter">table</replaceable>.<replaceable class="parameter">column</replaceable> | NONE } ]
  ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
+ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
    </synopsis>
   </refsynopsisdiv>
  
***************
*** 190,195 ****
--- 191,207 ----
         </para>
        </listitem>
       </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>RENAME TO</literal> <replaceable class="parameter">new_name</replaceable></term>
+     <listitem>
+      <para>
+       The <literal>RENAME TO</literal> option causes the sequence to be
+       renamed.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
      </variablelist>
     </para>
    </refsect1>
Index: src/backend/commands/alter.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/alter.c,v
retrieving revision 1.23
diff -c -r1.23 alter.c
*** src/backend/commands/alter.c	26 Mar 2007 16:58:38 -0000	1.23
--- src/backend/commands/alter.c	30 Jun 2007 00:14:47 -0000
***************
*** 83,88 ****
--- 83,90 ----
  			break;
  
  		case OBJECT_TABLE:
+ 		case OBJECT_SEQUENCE:
+ 		case OBJECT_VIEW:
  		case OBJECT_INDEX:
  		case OBJECT_COLUMN:
  		case OBJECT_TRIGGER:
***************
*** 96,101 ****
--- 98,105 ----
  				switch (stmt->renameType)
  				{
  					case OBJECT_TABLE:
+ 					case OBJECT_SEQUENCE:
+ 					case OBJECT_VIEW:
  					case OBJECT_INDEX:
  						{
  							/*
Index: src/backend/commands/tablecmds.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/tablecmds.c,v
retrieving revision 1.228
diff -c -r1.228 tablecmds.c
*** src/backend/commands/tablecmds.c	23 Jun 2007 22:12:50 -0000	1.228
--- src/backend/commands/tablecmds.c	30 Jun 2007 00:14:48 -0000
***************
*** 1633,1640 ****
  	bool		relhastriggers;
  
  	/*
! 	 * Grab an exclusive lock on the target table or index, which we will NOT
! 	 * release until end of transaction.
  	 */
  	targetrelation = relation_open(myrelid, AccessExclusiveLock);
  
--- 1633,1640 ----
  	bool		relhastriggers;
  
  	/*
! 	 * Grab an exclusive lock on the target table, index, sequence or
! 	 * view, which we will NOT release until end of transaction.
  	 */
  	targetrelation = relation_open(myrelid, AccessExclusiveLock);
  
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.596
diff -c -r2.596 gram.y
*** src/backend/parser/gram.y	23 Jun 2007 22:12:51 -0000	2.596
--- src/backend/parser/gram.y	30 Jun 2007 00:14:50 -0000
***************
*** 4546,4551 ****
--- 4546,4569 ----
  					n->newname = $6;
  					$$ = (Node *)n;
  				}
+ 			| ALTER SEQUENCE relation_expr RENAME TO name
+ 				{
+ 					RenameStmt *n = makeNode(RenameStmt);
+ 					n->renameType = OBJECT_SEQUENCE;
+ 					n->relation = $3;
+ 					n->subname = NULL;
+ 					n->newname = $6;
+ 					$$ = (Node *)n;
+ 				}
+ 			| ALTER VIEW relation_expr RENAME TO name
+ 				{
+ 					RenameStmt *n = makeNode(RenameStmt);
+ 					n->renameType = OBJECT_VIEW;
+ 					n->relation = $3;
+ 					n->subname = NULL;
+ 					n->newname = $6;
+ 					$$ = (Node *)n;
+ 				}
  			| ALTER INDEX relation_expr RENAME TO name
  				{
  					RenameStmt *n = makeNode(RenameStmt);
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/tcop/utility.c,v
retrieving revision 1.282
diff -c -r1.282 utility.c
*** src/backend/tcop/utility.c	28 Jun 2007 00:02:39 -0000	1.282
--- src/backend/tcop/utility.c	30 Jun 2007 00:14:50 -0000
***************
*** 1574,1579 ****
--- 1574,1582 ----
  				case OBJECT_SCHEMA:
  					tag = "ALTER SCHEMA";
  					break;
+ 				case OBJECT_SEQUENCE:
+ 					tag = "ALTER SEQUENCE";
+ 					break;
  				case OBJECT_COLUMN:
  				case OBJECT_TABLE:
  					tag = "ALTER TABLE";
***************
*** 1584,1589 ****
--- 1587,1595 ----
  				case OBJECT_TRIGGER:
  					tag = "ALTER TRIGGER";
  					break;
+ 				case OBJECT_VIEW:
+ 					tag = "ALTER VIEW";
+ 					break;
  				default:
  					tag = "???";
  					break;
Index: src/bin/psql/tab-complete.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/tab-complete.c,v
retrieving revision 1.165
diff -c -r1.165 tab-complete.c
*** src/bin/psql/tab-complete.c	13 Jun 2007 23:59:47 -0000	1.165
--- src/bin/psql/tab-complete.c	30 Jun 2007 00:14:51 -0000
***************
*** 602,608 ****
  		static const char *const list_ALTER[] =
  		{"AGGREGATE", "CONVERSION", "DATABASE", "DOMAIN", "FUNCTION",
  			"GROUP", "INDEX", "LANGUAGE", "OPERATOR", "ROLE", "SCHEMA", "SEQUENCE", "TABLE",
! 		"TABLESPACE", "TRIGGER", "TYPE", "USER", NULL};
  
  		COMPLETE_WITH_LIST(list_ALTER);
  	}
--- 602,608 ----
  		static const char *const list_ALTER[] =
  		{"AGGREGATE", "CONVERSION", "DATABASE", "DOMAIN", "FUNCTION",
  			"GROUP", "INDEX", "LANGUAGE", "OPERATOR", "ROLE", "SCHEMA", "SEQUENCE", "TABLE",
! 		"TABLESPACE", "TRIGGER", "TYPE", "USER", "VIEW", NULL};
  
  		COMPLETE_WITH_LIST(list_ALTER);
  	}
***************
*** 714,720 ****
  	{
  		static const char *const list_ALTERSEQUENCE[] =
  		{"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE",
! 		"SET SCHEMA", NULL};
  
  		COMPLETE_WITH_LIST(list_ALTERSEQUENCE);
  	}
--- 714,720 ----
  	{
  		static const char *const list_ALTERSEQUENCE[] =
  		{"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE",
! 		"SET SCHEMA", "RENAME TO", NULL};
  
  		COMPLETE_WITH_LIST(list_ALTERSEQUENCE);
  	}
***************
*** 728,733 ****
--- 728,742 ----
  
  		COMPLETE_WITH_LIST(list_ALTERSEQUENCE2);
  	}
+ 	/* ALTER VIEW <name> */
+ 	else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
+ 			 pg_strcasecmp(prev2_wd, "VIEW") == 0)
+ 	{
+ 		static const char *const list_ALTERVIEW[] =
+ 		{"RENAME TO"};
+ 
+ 		COMPLETE_WITH_LIST(list_ALTERVIEW);
+ 	}
  	/* ALTER TRIGGER <name>, add ON */
  	else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
  			 pg_strcasecmp(prev2_wd, "TRIGGER") == 0)
