diff --git a/doc/src/sgml/ref/alter_index.sgml b/doc/src/sgml/ref/alter_index.sgml
index 7ea1f2e97a5..c212fd09f93 100644
--- a/doc/src/sgml/ref/alter_index.sgml
+++ b/doc/src/sgml/ref/alter_index.sgml
@@ -1,5 +1,5 @@
@@ -20,13 +20,8 @@ PostgreSQL documentation
-ALTER INDEX name action [, ... ]
ALTER INDEX name RENAME TO new_name
-
-where action is one of:
-
- OWNER TO new_owner
- SET TABLESPACE indexspace_name
+ALTER INDEX name SET TABLESPACE tablespace_name
@@ -40,11 +35,11 @@ where action is one of:
- OWNER
+ RENAME
- This form changes the owner of the index to the
- specified user. This can only be done by a superuser.
+ The RENAME form changes the name of the index.
+ There is no effect on the stored data.
@@ -61,24 +56,9 @@ where action is one of:
-
- RENAME
-
-
- The RENAME form changes the name of the index.
- There is no effect on the stored data.
-
-
-
-
-
- All the actions except RENAME can be combined into
- a list of multiple alterations to apply in parallel.
-
-
@@ -90,28 +70,17 @@ where action is one of:
name
- The name (possibly schema-qualified) of an existing index to
- alter.
+ The name (possibly schema-qualified) of an existing index to
+ alter.
-
new_name
- New name for the index.
-
-
-
-
-
-
- new_owner
-
-
- The user name of the new owner of the index.
+ New name for the index.
@@ -120,7 +89,7 @@ where action is one of:
tablespace_name
- The tablespace name to which the index will be moved.
+ The tablespace to which the index will be moved.
@@ -138,6 +107,13 @@ where action is one of:
of ALTER TABLE> that apply to indexes.
+
+ There was formerly an ALTER INDEX OWNER> variant, but
+ this is now ignored (with a warning). An index cannot have an owner
+ different from its table's owner. Changing the table's owner
+ automatically changes the index as well.
+
+
Changing any part of a system catalog index is not permitted.
@@ -153,7 +129,7 @@ ALTER INDEX distributors RENAME TO suppliers;
- To move a index to a different tablespace:
+ To move an index to a different tablespace:
ALTER INDEX distributors SET TABLESPACE fasttablespace;
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 95e3ef68bb0..f2dd4a5a47d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.167 2005/08/22 17:38:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.168 2005/08/22 19:40:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -5279,6 +5279,25 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing)
/* ok to change owner */
break;
case RELKIND_INDEX:
+ if (!recursing)
+ {
+ /*
+ * Because ALTER INDEX OWNER used to be allowed, and in fact
+ * is generated by old versions of pg_dump, we give a warning
+ * and do nothing rather than erroring out. Also, to avoid
+ * unnecessary chatter while restoring those old dumps, say
+ * nothing at all if the command would be a no-op anyway.
+ */
+ if (tuple_class->relowner != newOwnerId)
+ ereport(WARNING,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cannot change owner of index \"%s\"",
+ NameStr(tuple_class->relname)),
+ errhint("Change the ownership of the index's table, instead.")));
+ /* quick hack to exit via the no-op path */
+ newOwnerId = tuple_class->relowner;
+ }
+ break;
case RELKIND_TOASTVALUE:
if (recursing)
break;
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 9bfed97424f..a8fb1d70f77 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.112 2005/08/12 01:35:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.113 2005/08/22 19:40:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2305,14 +2305,9 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
strcmp(type, "SEQUENCE") == 0)
type = "TABLE";
- /* We assume CONSTRAINTs are always pkey/unique indexes */
- if (strcmp(type, "CONSTRAINT") == 0)
- type = "INDEX";
-
/* objects named by a schema and name */
if (strcmp(type, "CONVERSION") == 0 ||
strcmp(type, "DOMAIN") == 0 ||
- strcmp(type, "INDEX") == 0 ||
strcmp(type, "TABLE") == 0 ||
strcmp(type, "TYPE") == 0)
{
@@ -2473,12 +2468,10 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
strlen(te->owner) > 0 && strlen(te->dropStmt) > 0)
{
if (strcmp(te->desc, "AGGREGATE") == 0 ||
- strcmp(te->desc, "CONSTRAINT") == 0 ||
strcmp(te->desc, "CONVERSION") == 0 ||
strcmp(te->desc, "DATABASE") == 0 ||
strcmp(te->desc, "DOMAIN") == 0 ||
strcmp(te->desc, "FUNCTION") == 0 ||
- strcmp(te->desc, "INDEX") == 0 ||
strcmp(te->desc, "OPERATOR") == 0 ||
strcmp(te->desc, "OPERATOR CLASS") == 0 ||
strcmp(te->desc, "SCHEMA") == 0 ||
@@ -2497,8 +2490,10 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
}
else if (strcmp(te->desc, "CAST") == 0 ||
strcmp(te->desc, "CHECK CONSTRAINT") == 0 ||
+ strcmp(te->desc, "CONSTRAINT") == 0 ||
strcmp(te->desc, "DEFAULT") == 0 ||
strcmp(te->desc, "FK CONSTRAINT") == 0 ||
+ strcmp(te->desc, "INDEX") == 0 ||
strcmp(te->desc, "PROCEDURAL LANGUAGE") == 0 ||
strcmp(te->desc, "RULE") == 0 ||
strcmp(te->desc, "TRIGGER") == 0)