 src/backend/catalog/objectaddress.c        |   14 ++
 src/backend/commands/alter.c               |  345 ++++++++++------------------
 src/backend/commands/collationcmds.c       |   73 ------
 src/backend/commands/conversioncmds.c      |   50 ----
 src/backend/commands/functioncmds.c        |   82 -------
 src/backend/commands/opclasscmds.c         |  104 ---------
 src/backend/commands/operatorcmds.c        |   53 -----
 src/backend/commands/tsearchcmds.c         |  188 ---------------
 src/backend/nodes/copyfuncs.c              |    1 -
 src/backend/nodes/equalfuncs.c             |    1 -
 src/backend/parser/gram.y                  |    4 +-
 src/include/catalog/objectaddress.h        |    1 +
 src/include/commands/alter.h               |    4 -
 src/include/commands/collationcmds.h       |    2 -
 src/include/commands/conversioncmds.h      |    2 -
 src/include/commands/defrem.h              |   17 --
 src/include/nodes/parsenodes.h             |    1 -
 src/test/regress/expected/alter_rename.out |   18 +-
 src/test/regress/sql/alter_rename.sql      |    9 +-
 19 files changed, 155 insertions(+), 814 deletions(-)

diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index bcf5259..9162c26 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -1485,6 +1485,20 @@ get_object_tuple(ObjectAddress address)
 }
 
 /*
+ * get_object_namespace_attnum
+ *
+ * It returns attribute number of namespace of the given object type,
+ * or InvalidAttrNumber if it is not an object under schema.
+ */
+AttrNumber
+get_object_namespace_attnum(const ObjectAddress *address)
+{
+	ObjectPropertyType *property
+		= get_object_property_data(address->classId);
+	return property->attnum_namespace;
+}
+
+/*
  * get_object_namespace
  *
  * Find the schema containing the specified object.  For non-schema objects,
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index c321224..2d60a99 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -181,6 +181,84 @@ ExecRenameStmt(RenameStmt *stmt)
 }
 
 /*
+ * AlterObjectSchemaInternal
+ *
+ * Generic function to change the namespace of a given object, for simple
+ * cases (won't work for tables, nor other cases where we need to do more
+ * than change the namespace column of a single catalog entry).
+ *
+ * this routine assumes the caller checks CREATE permission on `new_schema'
+ * via LookupCreationNamespace().
+ */
+static Oid
+AlterObjectSchemaInternal(ObjectAddress address,
+						  Oid new_schema, Relation relation)
+{
+	Relation	catalog;
+	Oid			old_schema;
+	HeapTuple	oldtup;
+	HeapTuple	newtup;
+	AttrNumber	Anum_namespace;
+	Datum		datum;
+	bool		isnull;
+	Datum	   *values;
+	bool	   *nulls;
+	bool	   *replaces;
+
+	catalog = heap_open(address.classId, RowExclusiveLock);
+
+	/* Fetch a tuple to be updated from the catalog */
+	Anum_namespace = get_object_namespace_attnum(&address);
+	oldtup = get_object_tuple(address);
+	datum = heap_getattr(oldtup, Anum_namespace,
+						 RelationGetDescr(catalog), &isnull);
+	Assert(!isnull);
+	old_schema = DatumGetObjectId(datum);
+
+	/* Check basic namespace related issues */
+	CheckSetNamespace(old_schema, new_schema,
+					  address.classId, address.objectId);
+
+	/* Permission checks */
+	check_object_ownership(GetUserId(), address, relation);
+
+	/* Check for duplicate names */
+	if (object_exists_namespace(address, new_schema, NULL))
+		ereport(ERROR,
+				(errcode(ERRCODE_DUPLICATE_OBJECT),
+				 errmsg("%s already exists in schema \"%s\"",
+						getObjectDescriptionOids(address.classId,
+												 address.objectId),
+						get_namespace_name(new_schema))));
+
+	/* Build modified tuple */
+	values = palloc0(RelationGetNumberOfAttributes(catalog) * sizeof(Datum));
+	nulls = palloc0(RelationGetNumberOfAttributes(catalog) * sizeof(bool));
+	replaces = palloc0(RelationGetNumberOfAttributes(catalog) * sizeof(bool));
+	values[Anum_namespace - 1] = ObjectIdGetDatum(new_schema);
+	replaces[Anum_namespace - 1] = true;
+	newtup = heap_modify_tuple(oldtup, RelationGetDescr(catalog),
+							   values, nulls, replaces);
+
+	/* Perform actual update */
+	simple_heap_update(catalog, &oldtup->t_self, newtup);
+	CatalogUpdateIndexes(catalog, newtup);
+
+	/* Release memory */
+	pfree(values);
+	pfree(nulls);
+	pfree(replaces);
+
+	/* update dependencies to point to the new schema */
+	changeDependencyFor(address.classId, address.objectId,
+						NamespaceRelationId, old_schema, new_schema);
+
+	heap_close(catalog, RowExclusiveLock);
+
+	return old_schema;
+}
+
+/*
  * Executes an ALTER OBJECT / SET SCHEMA statement.  Based on the object
  * type, the function appropriate to that type is executed.
  */
@@ -189,73 +267,70 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
 {
 	switch (stmt->objectType)
 	{
-		case OBJECT_AGGREGATE:
-			AlterFunctionNamespace(stmt->object, stmt->objarg, true,
-								   stmt->newschema);
-			break;
-
-		case OBJECT_COLLATION:
-			AlterCollationNamespace(stmt->object, stmt->newschema);
-			break;
-
-		case OBJECT_CONVERSION:
-			AlterConversionNamespace(stmt->object, stmt->newschema);
-			break;
-
 		case OBJECT_EXTENSION:
+			/*
+			 * ALTER EXTENSION tries to set schema on underlying objects,
+			 * so it is unavailable to consolidate with common routine.
+			 */
 			AlterExtensionNamespace(stmt->object, stmt->newschema);
 			break;
 
-		case OBJECT_FUNCTION:
-			AlterFunctionNamespace(stmt->object, stmt->objarg, false,
-								   stmt->newschema);
-			break;
-
-		case OBJECT_OPERATOR:
-			AlterOperatorNamespace(stmt->object, stmt->objarg, stmt->newschema);
-			break;
-
-		case OBJECT_OPCLASS:
-			AlterOpClassNamespace(stmt->object, stmt->addname, stmt->newschema);
-			break;
-
-		case OBJECT_OPFAMILY:
-			AlterOpFamilyNamespace(stmt->object, stmt->addname, stmt->newschema);
-			break;
-
 		case OBJECT_SEQUENCE:
 		case OBJECT_TABLE:
 		case OBJECT_VIEW:
 		case OBJECT_FOREIGN_TABLE:
+			/*
+			 * ALTER "TABLE" is allowed to use for VIEW, SEQUENCE or FOREIGN
+			 * TABLE, so it is unavailable to consolidate with common routine.
+			 */
 			CheckRelationOwnership(stmt->relation, true);
 			AlterTableNamespace(stmt->relation, stmt->newschema,
 								stmt->objectType, AccessExclusiveLock);
 			break;
 
-		case OBJECT_TSPARSER:
-			AlterTSParserNamespace(stmt->object, stmt->newschema);
+		case OBJECT_TYPE:
+		case OBJECT_DOMAIN:
+			/*
+			 * ALTER TYPE also alters namespace of the composite table's
+			 * definition on pg_class, so it is unavailable to consolidate
+			 * with common routine.
+			 */
+			AlterTypeNamespace(stmt->object, stmt->newschema);
 			break;
 
+		case OBJECT_AGGREGATE:
+		case OBJECT_COLLATION:
+		case OBJECT_CONVERSION:
+		case OBJECT_FUNCTION:
+		case OBJECT_OPERATOR:
+		case OBJECT_OPCLASS:
+		case OBJECT_OPFAMILY:
+		case OBJECT_TSPARSER:
 		case OBJECT_TSDICTIONARY:
-			AlterTSDictionaryNamespace(stmt->object, stmt->newschema);
-			break;
-
 		case OBJECT_TSTEMPLATE:
-			AlterTSTemplateNamespace(stmt->object, stmt->newschema);
-			break;
-
 		case OBJECT_TSCONFIGURATION:
-			AlterTSConfigurationNamespace(stmt->object, stmt->newschema);
-			break;
+			{
+				ObjectAddress	address;
+				Relation	relation = NULL;
+				Oid			new_schema;
 
-		case OBJECT_TYPE:
-		case OBJECT_DOMAIN:
-			AlterTypeNamespace(stmt->object, stmt->newschema);
-			break;
+				address = get_object_address(stmt->objectType,
+											 stmt->object, stmt->objarg,
+											 &relation,
+											 AccessExclusiveLock, false);
 
+				new_schema = LookupCreationNamespace(stmt->newschema);
+
+				AlterObjectSchemaInternal(address, new_schema, relation);
+
+				if (relation)
+					heap_close(relation, NoLock);
+			}
+			break;
 		default:
 			elog(ERROR, "unrecognized AlterObjectSchemaStmt type: %d",
 				 (int) stmt->objectType);
+			break;
 	}
 }
 
@@ -277,6 +352,7 @@ Oid
 AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid)
 {
 	Oid			oldNspOid = InvalidOid;
+	Relation	relation = NULL;
 	ObjectAddress dep;
 
 	dep.classId = classId;
@@ -285,204 +361,35 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid)
 
 	switch (getObjectClass(&dep))
 	{
-		case OCLASS_CLASS:
-			{
-				Relation	rel;
-				Relation	classRel;
-
-				rel = relation_open(objid, AccessExclusiveLock);
-				oldNspOid = RelationGetNamespace(rel);
-
-				classRel = heap_open(RelationRelationId, RowExclusiveLock);
-
-				AlterRelationNamespaceInternal(classRel,
-											   objid,
-											   oldNspOid,
-											   nspOid,
-											   true);
-
-				heap_close(classRel, RowExclusiveLock);
-
-				relation_close(rel, NoLock);
-				break;
-			}
-
-		case OCLASS_PROC:
-			oldNspOid = AlterFunctionNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_TYPE:
 			oldNspOid = AlterTypeNamespace_oid(objid, nspOid);
 			break;
 
+		case OCLASS_CLASS:
+			relation = relation_open(objid, AccessExclusiveLock);
+		case OCLASS_PROC:
 		case OCLASS_COLLATION:
-			oldNspOid = AlterCollationNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_CONVERSION:
-			oldNspOid = AlterConversionNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_OPERATOR:
-			oldNspOid = AlterOperatorNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_OPCLASS:
-			oldNspOid = AlterOpClassNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_OPFAMILY:
-			oldNspOid = AlterOpFamilyNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_TSPARSER:
-			oldNspOid = AlterTSParserNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_TSDICT:
-			oldNspOid = AlterTSDictionaryNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_TSTEMPLATE:
-			oldNspOid = AlterTSTemplateNamespace_oid(objid, nspOid);
-			break;
-
 		case OCLASS_TSCONFIG:
-			oldNspOid = AlterTSConfigurationNamespace_oid(objid, nspOid);
+			oldNspOid = AlterObjectSchemaInternal(dep, nspOid, relation);
 			break;
 
 		default:
 			break;
 	}
+	if (relation)
+		heap_close(relation, NoLock);
 
 	return oldNspOid;
 }
 
 /*
- * Generic function to change the namespace of a given object, for simple
- * cases (won't work for tables, nor other cases where we need to do more
- * than change the namespace column of a single catalog entry).
- *
- * The AlterFooNamespace() calls just above will call a function whose job
- * is to lookup the arguments for the generic function here.
- *
- * rel: catalog relation containing object (RowExclusiveLock'd by caller)
- * oidCacheId: syscache that indexes this catalog by OID
- * nameCacheId: syscache that indexes this catalog by name and namespace
- *		(pass -1 if there is none)
- * objid: OID of object to change the namespace of
- * nspOid: OID of new namespace
- * Anum_name: column number of catalog's name column
- * Anum_namespace: column number of catalog's namespace column
- * Anum_owner: column number of catalog's owner column, or -1 if none
- * acl_kind: ACL type for object, or -1 if none assigned
- *
- * If the object does not have an owner or permissions, pass -1 for
- * Anum_owner and acl_kind.  In this case the calling user must be superuser.
- *
- * Returns the OID of the object's previous namespace.
- */
-Oid
-AlterObjectNamespace(Relation rel, int oidCacheId, int nameCacheId,
-					 Oid objid, Oid nspOid,
-					 int Anum_name, int Anum_namespace, int Anum_owner,
-					 AclObjectKind acl_kind)
-{
-	Oid			classId = RelationGetRelid(rel);
-	Oid			oldNspOid;
-	Datum		name,
-				namespace;
-	bool		isnull;
-	HeapTuple	tup,
-				newtup;
-	Datum	   *values;
-	bool	   *nulls;
-	bool	   *replaces;
-
-	tup = SearchSysCacheCopy1(oidCacheId, ObjectIdGetDatum(objid));
-	if (!HeapTupleIsValid(tup)) /* should not happen */
-		elog(ERROR, "cache lookup failed for object %u of catalog \"%s\"",
-			 objid, RelationGetRelationName(rel));
-
-	name = heap_getattr(tup, Anum_name, RelationGetDescr(rel), &isnull);
-	Assert(!isnull);
-	namespace = heap_getattr(tup, Anum_namespace, RelationGetDescr(rel), &isnull);
-	Assert(!isnull);
-	oldNspOid = DatumGetObjectId(namespace);
-
-	/* Check basic namespace related issues */
-	CheckSetNamespace(oldNspOid, nspOid, classId, objid);
-
-	/* Permission checks ... superusers can always do it */
-	if (!superuser())
-	{
-		Datum		owner;
-		Oid			ownerId;
-		AclResult	aclresult;
-
-		/* Fail if object does not have an explicit owner */
-		if (Anum_owner <= 0)
-			ereport(ERROR,
-					(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-					 (errmsg("must be superuser to set schema of %s",
-							 getObjectDescriptionOids(classId, objid)))));
-
-		/* Otherwise, must be owner of the existing object */
-		owner = heap_getattr(tup, Anum_owner, RelationGetDescr(rel), &isnull);
-		Assert(!isnull);
-		ownerId = DatumGetObjectId(owner);
-
-		if (!has_privs_of_role(GetUserId(), ownerId))
-			aclcheck_error(ACLCHECK_NOT_OWNER, acl_kind,
-						   NameStr(*(DatumGetName(name))));
-
-		/* User must have CREATE privilege on new namespace */
-		aclresult = pg_namespace_aclcheck(nspOid, GetUserId(), ACL_CREATE);
-		if (aclresult != ACLCHECK_OK)
-			aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
-						   get_namespace_name(nspOid));
-	}
-
-	/*
-	 * Check for duplicate name (more friendly than unique-index failure).
-	 * Since this is just a friendliness check, we can just skip it in cases
-	 * where there isn't a suitable syscache available.
-	 */
-	if (nameCacheId >= 0 &&
-		SearchSysCacheExists2(nameCacheId, name, ObjectIdGetDatum(nspOid)))
-		ereport(ERROR,
-				(errcode(ERRCODE_DUPLICATE_OBJECT),
-				 errmsg("%s already exists in schema \"%s\"",
-						getObjectDescriptionOids(classId, objid),
-						get_namespace_name(nspOid))));
-
-	/* Build modified tuple */
-	values = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(Datum));
-	nulls = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(bool));
-	replaces = palloc0(RelationGetNumberOfAttributes(rel) * sizeof(bool));
-	values[Anum_namespace - 1] = ObjectIdGetDatum(nspOid);
-	replaces[Anum_namespace - 1] = true;
-	newtup = heap_modify_tuple(tup, RelationGetDescr(rel),
-							   values, nulls, replaces);
-
-	/* Perform actual update */
-	simple_heap_update(rel, &tup->t_self, newtup);
-	CatalogUpdateIndexes(rel, newtup);
-
-	/* Release memory */
-	pfree(values);
-	pfree(nulls);
-	pfree(replaces);
-
-	/* update dependencies to point to the new schema */
-	changeDependencyFor(classId, objid,
-						NamespaceRelationId, oldNspOid, nspOid);
-
-	return oldNspOid;
-}
-
-
-/*
  * Executes an ALTER OBJECT / OWNER TO statement.  Based on the object
  * type, the function appropriate to that type is executed.
  */
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index 20aa204..09020d1 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -307,76 +307,3 @@ AlterCollationOwner_internal(Relation rel, Oid collationOid, Oid newOwnerId)
 
 	heap_freetuple(tup);
 }
-
-/*
- * Execute ALTER COLLATION SET SCHEMA
- */
-void
-AlterCollationNamespace(List *name, const char *newschema)
-{
-	Oid			collOid,
-				nspOid;
-
-	collOid = get_collation_oid(name, false);
-
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterCollationNamespace_oid(collOid, nspOid);
-}
-
-/*
- * Change collation schema, by oid
- */
-Oid
-AlterCollationNamespace_oid(Oid collOid, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-	char	   *collation_name;
-
-	rel = heap_open(CollationRelationId, RowExclusiveLock);
-
-	/*
-	 * We have to check for name collision ourselves, because
-	 * AlterObjectNamespace doesn't know how to deal with the encoding
-	 * considerations.
-	 */
-	collation_name = get_collation_name(collOid);
-	if (!collation_name)
-		elog(ERROR, "cache lookup failed for collation %u", collOid);
-
-	/* make sure the name doesn't already exist in new schema */
-	if (SearchSysCacheExists3(COLLNAMEENCNSP,
-							  CStringGetDatum(collation_name),
-							  Int32GetDatum(GetDatabaseEncoding()),
-							  ObjectIdGetDatum(newNspOid)))
-		ereport(ERROR,
-				(errcode(ERRCODE_DUPLICATE_OBJECT),
-				 errmsg("collation \"%s\" for encoding \"%s\" already exists in schema \"%s\"",
-						collation_name,
-						GetDatabaseEncodingName(),
-						get_namespace_name(newNspOid))));
-
-	/* mustn't match an any-encoding entry, either */
-	if (SearchSysCacheExists3(COLLNAMEENCNSP,
-							  CStringGetDatum(collation_name),
-							  Int32GetDatum(-1),
-							  ObjectIdGetDatum(newNspOid)))
-		ereport(ERROR,
-				(errcode(ERRCODE_DUPLICATE_OBJECT),
-				 errmsg("collation \"%s\" already exists in schema \"%s\"",
-						collation_name,
-						get_namespace_name(newNspOid))));
-
-	/* OK, do the work */
-	oldNspOid = AlterObjectNamespace(rel, COLLOID, -1,
-									 collOid, newNspOid,
-									 Anum_pg_collation_collname,
-									 Anum_pg_collation_collnamespace,
-									 Anum_pg_collation_collowner,
-									 ACL_KIND_COLLATION);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
index 7d6063d..950f870 100644
--- a/src/backend/commands/conversioncmds.c
+++ b/src/backend/commands/conversioncmds.c
@@ -265,53 +265,3 @@ AlterConversionOwner_internal(Relation rel, Oid conversionOid, Oid newOwnerId)
 
 	heap_freetuple(tup);
 }
-
-/*
- * Execute ALTER CONVERSION SET SCHEMA
- */
-void
-AlterConversionNamespace(List *name, const char *newschema)
-{
-	Oid			convOid,
-				nspOid;
-	Relation	rel;
-
-	rel = heap_open(ConversionRelationId, RowExclusiveLock);
-
-	convOid = get_conversion_oid(name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, CONVOID, CONNAMENSP,
-						 convOid, nspOid,
-						 Anum_pg_conversion_conname,
-						 Anum_pg_conversion_connamespace,
-						 Anum_pg_conversion_conowner,
-						 ACL_KIND_CONVERSION);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-/*
- * Change conversion schema, by oid
- */
-Oid
-AlterConversionNamespace_oid(Oid convOid, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(ConversionRelationId, RowExclusiveLock);
-
-	oldNspOid = AlterObjectNamespace(rel, CONVOID, CONNAMENSP,
-									 convOid, newNspOid,
-									 Anum_pg_conversion_conname,
-									 Anum_pg_conversion_connamespace,
-									 Anum_pg_conversion_conowner,
-									 ACL_KIND_CONVERSION);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 09a975b..5102d87 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1760,88 +1760,6 @@ DropCastById(Oid castOid)
 }
 
 /*
- * Execute ALTER FUNCTION/AGGREGATE SET SCHEMA
- *
- * These commands are identical except for the lookup procedure, so share code.
- */
-void
-AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
-					   const char *newschema)
-{
-	Oid			procOid;
-	Oid			nspOid;
-
-	/* get function OID */
-	if (isagg)
-		procOid = LookupAggNameTypeNames(name, argtypes, false);
-	else
-		procOid = LookupFuncNameTypeNames(name, argtypes, false);
-
-	/* get schema OID and check its permissions */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterFunctionNamespace_oid(procOid, nspOid);
-}
-
-Oid
-AlterFunctionNamespace_oid(Oid procOid, Oid nspOid)
-{
-	Oid			oldNspOid;
-	HeapTuple	tup;
-	Relation	procRel;
-	Form_pg_proc proc;
-
-	procRel = heap_open(ProcedureRelationId, RowExclusiveLock);
-
-	tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(procOid));
-	if (!HeapTupleIsValid(tup))
-		elog(ERROR, "cache lookup failed for function %u", procOid);
-	proc = (Form_pg_proc) GETSTRUCT(tup);
-
-	/* check permissions on function */
-	if (!pg_proc_ownercheck(procOid, GetUserId()))
-		aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
-					   NameStr(proc->proname));
-
-	oldNspOid = proc->pronamespace;
-
-	/* common checks on switching namespaces */
-	CheckSetNamespace(oldNspOid, nspOid, ProcedureRelationId, procOid);
-
-	/* check for duplicate name (more friendly than unique-index failure) */
-	if (SearchSysCacheExists3(PROCNAMEARGSNSP,
-							  CStringGetDatum(NameStr(proc->proname)),
-							  PointerGetDatum(&proc->proargtypes),
-							  ObjectIdGetDatum(nspOid)))
-		ereport(ERROR,
-				(errcode(ERRCODE_DUPLICATE_FUNCTION),
-				 errmsg("function \"%s\" already exists in schema \"%s\"",
-						NameStr(proc->proname),
-						get_namespace_name(nspOid))));
-
-	/* OK, modify the pg_proc row */
-
-	/* tup is a copy, so we can scribble directly on it */
-	proc->pronamespace = nspOid;
-
-	simple_heap_update(procRel, &tup->t_self, tup);
-	CatalogUpdateIndexes(procRel, tup);
-
-	/* Update dependency on schema */
-	if (changeDependencyFor(ProcedureRelationId, procOid,
-							NamespaceRelationId, oldNspOid, nspOid) != 1)
-		elog(ERROR, "failed to change schema dependency for function \"%s\"",
-			 NameStr(proc->proname));
-
-	heap_freetuple(tup);
-
-	heap_close(procRel, RowExclusiveLock);
-
-	return oldNspOid;
-}
-
-
-/*
  * ExecuteDoStmt
  *		Execute inline procedural-language code
  */
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 0ef3584..7598561 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -1896,58 +1896,6 @@ AlterOpClassOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
 }
 
 /*
- * ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
- */
-void
-AlterOpClassNamespace(List *name, char *access_method, const char *newschema)
-{
-	Oid			amOid;
-	Relation	rel;
-	Oid			opclassOid;
-	Oid			nspOid;
-
-	amOid = get_am_oid(access_method, false);
-
-	rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
-
-	/* Look up the opclass */
-	opclassOid = get_opclass_oid(amOid, name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, CLAOID, -1,
-						 opclassOid, nspOid,
-						 Anum_pg_opclass_opcname,
-						 Anum_pg_opclass_opcnamespace,
-						 Anum_pg_opclass_opcowner,
-						 ACL_KIND_OPCLASS);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterOpClassNamespace_oid(Oid opclassOid, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
-
-	oldNspOid =
-		AlterObjectNamespace(rel, CLAOID, -1,
-							 opclassOid, newNspOid,
-							 Anum_pg_opclass_opcname,
-							 Anum_pg_opclass_opcnamespace,
-							 Anum_pg_opclass_opcowner,
-							 ACL_KIND_OPCLASS);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
-
-/*
  * Change opfamily owner by name
  */
 void
@@ -2103,55 +2051,3 @@ get_am_oid(const char *amname, bool missing_ok)
 				 errmsg("access method \"%s\" does not exist", amname)));
 	return oid;
 }
-
-/*
- * ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
- */
-void
-AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema)
-{
-	Oid			amOid;
-	Relation	rel;
-	Oid			opfamilyOid;
-	Oid			nspOid;
-
-	amOid = get_am_oid(access_method, false);
-
-	rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
-
-	/* Look up the opfamily */
-	opfamilyOid = get_opfamily_oid(amOid, name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, OPFAMILYOID, -1,
-						 opfamilyOid, nspOid,
-						 Anum_pg_opfamily_opfname,
-						 Anum_pg_opfamily_opfnamespace,
-						 Anum_pg_opfamily_opfowner,
-						 ACL_KIND_OPFAMILY);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterOpFamilyNamespace_oid(Oid opfamilyOid, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
-
-	oldNspOid =
-		AlterObjectNamespace(rel, OPFAMILYOID, -1,
-							 opfamilyOid, newNspOid,
-							 Anum_pg_opfamily_opfname,
-							 Anum_pg_opfamily_opfnamespace,
-							 Anum_pg_opfamily_opfowner,
-							 ACL_KIND_OPFAMILY);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index 1e6c5ce..1037c45 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -401,56 +401,3 @@ AlterOperatorOwner_internal(Relation rel, Oid operOid, Oid newOwnerId)
 
 	heap_freetuple(tup);
 }
-
-/*
- * Execute ALTER OPERATOR SET SCHEMA
- */
-void
-AlterOperatorNamespace(List *names, List *argtypes, const char *newschema)
-{
-	List	   *operatorName = names;
-	TypeName   *typeName1 = (TypeName *) linitial(argtypes);
-	TypeName   *typeName2 = (TypeName *) lsecond(argtypes);
-	Oid			operOid,
-				nspOid;
-	Relation	rel;
-
-	rel = heap_open(OperatorRelationId, RowExclusiveLock);
-
-	Assert(list_length(argtypes) == 2);
-	operOid = LookupOperNameTypeNames(NULL, operatorName,
-									  typeName1, typeName2,
-									  false, -1);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, OPEROID, -1,
-						 operOid, nspOid,
-						 Anum_pg_operator_oprname,
-						 Anum_pg_operator_oprnamespace,
-						 Anum_pg_operator_oprowner,
-						 ACL_KIND_OPER);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterOperatorNamespace_oid(Oid operOid, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(OperatorRelationId, RowExclusiveLock);
-
-	oldNspOid = AlterObjectNamespace(rel, OPEROID, -1,
-									 operOid, newNspOid,
-									 Anum_pg_operator_oprname,
-									 Anum_pg_operator_oprnamespace,
-									 Anum_pg_operator_oprowner,
-									 ACL_KIND_OPER);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 5f206d8..471d6d1 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -344,52 +344,6 @@ RenameTSParser(List *oldname, const char *newname)
 	heap_freetuple(tup);
 }
 
-/*
- * ALTER TEXT SEARCH PARSER any_name SET SCHEMA name
- */
-void
-AlterTSParserNamespace(List *name, const char *newschema)
-{
-	Oid			prsId,
-				nspOid;
-	Relation	rel;
-
-	rel = heap_open(TSParserRelationId, RowExclusiveLock);
-
-	prsId = get_ts_parser_oid(name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, TSPARSEROID, TSPARSERNAMENSP,
-						 prsId, nspOid,
-						 Anum_pg_ts_parser_prsname,
-						 Anum_pg_ts_parser_prsnamespace,
-						 -1, -1);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterTSParserNamespace_oid(Oid prsId, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(TSParserRelationId, RowExclusiveLock);
-
-	oldNspOid =
-		AlterObjectNamespace(rel, TSPARSEROID, TSPARSERNAMENSP,
-							 prsId, newNspOid,
-							 Anum_pg_ts_parser_prsname,
-							 Anum_pg_ts_parser_prsnamespace,
-							 -1, -1);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
-
 /* ---------------------- TS Dictionary commands -----------------------*/
 
 /*
@@ -624,54 +578,6 @@ RenameTSDictionary(List *oldname, const char *newname)
 }
 
 /*
- * ALTER TEXT SEARCH DICTIONARY any_name SET SCHEMA name
- */
-void
-AlterTSDictionaryNamespace(List *name, const char *newschema)
-{
-	Oid			dictId,
-				nspOid;
-	Relation	rel;
-
-	rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
-
-	dictId = get_ts_dict_oid(name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, TSDICTOID, TSDICTNAMENSP,
-						 dictId, nspOid,
-						 Anum_pg_ts_dict_dictname,
-						 Anum_pg_ts_dict_dictnamespace,
-						 Anum_pg_ts_dict_dictowner,
-						 ACL_KIND_TSDICTIONARY);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterTSDictionaryNamespace_oid(Oid dictId, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
-
-	oldNspOid =
-		AlterObjectNamespace(rel, TSDICTOID, TSDICTNAMENSP,
-							 dictId, newNspOid,
-							 Anum_pg_ts_dict_dictname,
-							 Anum_pg_ts_dict_dictnamespace,
-							 Anum_pg_ts_dict_dictowner,
-							 ACL_KIND_TSDICTIONARY);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
-
-/*
  * Guts of TS dictionary deletion.
  */
 void
@@ -1088,52 +994,6 @@ RenameTSTemplate(List *oldname, const char *newname)
 }
 
 /*
- * ALTER TEXT SEARCH TEMPLATE any_name SET SCHEMA name
- */
-void
-AlterTSTemplateNamespace(List *name, const char *newschema)
-{
-	Oid			tmplId,
-				nspOid;
-	Relation	rel;
-
-	rel = heap_open(TSTemplateRelationId, RowExclusiveLock);
-
-	tmplId = get_ts_template_oid(name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, TSTEMPLATEOID, TSTEMPLATENAMENSP,
-						 tmplId, nspOid,
-						 Anum_pg_ts_template_tmplname,
-						 Anum_pg_ts_template_tmplnamespace,
-						 -1, -1);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterTSTemplateNamespace_oid(Oid tmplId, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(TSTemplateRelationId, RowExclusiveLock);
-
-	oldNspOid =
-		AlterObjectNamespace(rel, TSTEMPLATEOID, TSTEMPLATENAMENSP,
-							 tmplId, newNspOid,
-							 Anum_pg_ts_template_tmplname,
-							 Anum_pg_ts_template_tmplnamespace,
-							 -1, -1);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
-
-/*
  * Guts of TS template deletion.
  */
 void
@@ -1479,54 +1339,6 @@ RenameTSConfiguration(List *oldname, const char *newname)
 }
 
 /*
- * ALTER TEXT SEARCH CONFIGURATION any_name SET SCHEMA name
- */
-void
-AlterTSConfigurationNamespace(List *name, const char *newschema)
-{
-	Oid			cfgId,
-				nspOid;
-	Relation	rel;
-
-	rel = heap_open(TSConfigRelationId, RowExclusiveLock);
-
-	cfgId = get_ts_config_oid(name, false);
-
-	/* get schema OID */
-	nspOid = LookupCreationNamespace(newschema);
-
-	AlterObjectNamespace(rel, TSCONFIGOID, TSCONFIGNAMENSP,
-						 cfgId, nspOid,
-						 Anum_pg_ts_config_cfgname,
-						 Anum_pg_ts_config_cfgnamespace,
-						 Anum_pg_ts_config_cfgowner,
-						 ACL_KIND_TSCONFIGURATION);
-
-	heap_close(rel, RowExclusiveLock);
-}
-
-Oid
-AlterTSConfigurationNamespace_oid(Oid cfgId, Oid newNspOid)
-{
-	Oid			oldNspOid;
-	Relation	rel;
-
-	rel = heap_open(TSConfigRelationId, RowExclusiveLock);
-
-	oldNspOid =
-		AlterObjectNamespace(rel, TSCONFIGOID, TSCONFIGNAMENSP,
-							 cfgId, newNspOid,
-							 Anum_pg_ts_config_cfgname,
-							 Anum_pg_ts_config_cfgnamespace,
-							 Anum_pg_ts_config_cfgowner,
-							 ACL_KIND_TSCONFIGURATION);
-
-	heap_close(rel, RowExclusiveLock);
-
-	return oldNspOid;
-}
-
-/*
  * Guts of TS configuration deletion.
  */
 void
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index b8f047a..6fa5ec1 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2914,7 +2914,6 @@ _copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from)
 	COPY_NODE_FIELD(relation);
 	COPY_NODE_FIELD(object);
 	COPY_NODE_FIELD(objarg);
-	COPY_STRING_FIELD(addname);
 	COPY_STRING_FIELD(newschema);
 
 	return newnode;
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index d1af48a..9ae95b0 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1319,7 +1319,6 @@ _equalAlterObjectSchemaStmt(AlterObjectSchemaStmt *a, AlterObjectSchemaStmt *b)
 	COMPARE_NODE_FIELD(relation);
 	COMPARE_NODE_FIELD(object);
 	COMPARE_NODE_FIELD(objarg);
-	COMPARE_STRING_FIELD(addname);
 	COMPARE_STRING_FIELD(newschema);
 
 	return true;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 7ea38e4..7940121 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -6765,7 +6765,7 @@ AlterObjectSchemaStmt:
 					AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
 					n->objectType = OBJECT_OPCLASS;
 					n->object = $4;
-					n->addname = $6;
+					n->objarg = list_make1(makeString($6));
 					n->newschema = $9;
 					$$ = (Node *)n;
 				}
@@ -6774,7 +6774,7 @@ AlterObjectSchemaStmt:
 					AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
 					n->objectType = OBJECT_OPFAMILY;
 					n->object = $4;
-					n->addname = $6;
+					n->objarg = list_make1(makeString($6));
 					n->newschema = $9;
 					$$ = (Node *)n;
 				}
diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
index ff7b957..a5d3325 100644
--- a/src/include/catalog/objectaddress.h
+++ b/src/include/catalog/objectaddress.h
@@ -42,6 +42,7 @@ extern bool object_exists_namespace(ObjectAddress address,
 
 extern HeapTuple get_object_tuple(ObjectAddress address);
 
+extern AttrNumber get_object_namespace_attnum(const ObjectAddress *address);
 extern Oid	get_object_namespace(const ObjectAddress *address);
 
 #endif   /* PARSE_OBJECT_H */
diff --git a/src/include/commands/alter.h b/src/include/commands/alter.h
index 6cf9de1..0186a48 100644
--- a/src/include/commands/alter.h
+++ b/src/include/commands/alter.h
@@ -20,10 +20,6 @@
 extern void ExecRenameStmt(RenameStmt *stmt);
 extern void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
 extern Oid	AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid);
-extern Oid AlterObjectNamespace(Relation rel, int oidCacheId, int nameCacheId,
-					 Oid objid, Oid nspOid,
-					 int Anum_name, int Anum_namespace, int Anum_owner,
-					 AclObjectKind acl_kind);
 extern void ExecAlterOwnerStmt(AlterOwnerStmt *stmt);
 
 #endif   /* ALTER_H */
diff --git a/src/include/commands/collationcmds.h b/src/include/commands/collationcmds.h
index ce4727c..d161d74 100644
--- a/src/include/commands/collationcmds.h
+++ b/src/include/commands/collationcmds.h
@@ -21,7 +21,5 @@ extern void DefineCollation(List *names, List *parameters);
 extern void RenameCollation(List *name, const char *newname);
 extern void AlterCollationOwner(List *name, Oid newOwnerId);
 extern void AlterCollationOwner_oid(Oid collationOid, Oid newOwnerId);
-extern void AlterCollationNamespace(List *name, const char *newschema);
-extern Oid	AlterCollationNamespace_oid(Oid collOid, Oid newNspOid);
 
 #endif   /* COLLATIONCMDS_H */
diff --git a/src/include/commands/conversioncmds.h b/src/include/commands/conversioncmds.h
index c0e7cd9..6a8a02f 100644
--- a/src/include/commands/conversioncmds.h
+++ b/src/include/commands/conversioncmds.h
@@ -21,7 +21,5 @@ extern void CreateConversionCommand(CreateConversionStmt *parsetree);
 extern void RenameConversion(List *name, const char *newname);
 extern void AlterConversionOwner(List *name, Oid newOwnerId);
 extern void AlterConversionOwner_oid(Oid conversionOid, Oid newOwnerId);
-extern void AlterConversionNamespace(List *name, const char *newschema);
-extern Oid	AlterConversionNamespace_oid(Oid convOid, Oid newNspOid);
 
 #endif   /* CONVERSIONCMDS_H */
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index f0dcf76..b4c0c91 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -70,9 +70,6 @@ extern void AlterFunctionOwner_oid(Oid procOid, Oid newOwnerId);
 extern void AlterFunction(AlterFunctionStmt *stmt);
 extern void CreateCast(CreateCastStmt *stmt);
 extern void DropCastById(Oid castOid);
-extern void AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
-					   const char *newschema);
-extern Oid	AlterFunctionNamespace_oid(Oid procOid, Oid nspOid);
 extern void ExecuteDoStmt(DoStmt *stmt);
 extern Oid	get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
 
@@ -82,8 +79,6 @@ extern void RemoveOperatorById(Oid operOid);
 extern void AlterOperatorOwner(List *name, TypeName *typeName1,
 				   TypeName *typename2, Oid newOwnerId);
 extern void AlterOperatorOwner_oid(Oid operOid, Oid newOwnerId);
-extern void AlterOperatorNamespace(List *names, List *argtypes, const char *newschema);
-extern Oid	AlterOperatorNamespace_oid(Oid operOid, Oid newNspOid);
 
 /* commands/aggregatecmds.c */
 extern void DefineAggregate(List *name, List *args, bool oldstyle,
@@ -103,12 +98,8 @@ extern void RenameOpClass(List *name, const char *access_method, const char *new
 extern void RenameOpFamily(List *name, const char *access_method, const char *newname);
 extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId);
 extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId);
-extern void AlterOpClassNamespace(List *name, char *access_method, const char *newschema);
-extern Oid	AlterOpClassNamespace_oid(Oid opclassOid, Oid newNspOid);
 extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId);
 extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId);
-extern void AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema);
-extern Oid	AlterOpFamilyNamespace_oid(Oid opfamilyOid, Oid newNspOid);
 extern Oid	get_am_oid(const char *amname, bool missing_ok);
 extern Oid	get_opclass_oid(Oid amID, List *opclassname, bool missing_ok);
 extern Oid	get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok);
@@ -116,8 +107,6 @@ extern Oid	get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok);
 /* commands/tsearchcmds.c */
 extern void DefineTSParser(List *names, List *parameters);
 extern void RenameTSParser(List *oldname, const char *newname);
-extern void AlterTSParserNamespace(List *name, const char *newschema);
-extern Oid	AlterTSParserNamespace_oid(Oid prsId, Oid newNspOid);
 extern void RemoveTSParserById(Oid prsId);
 
 extern void DefineTSDictionary(List *names, List *parameters);
@@ -125,13 +114,9 @@ extern void RenameTSDictionary(List *oldname, const char *newname);
 extern void RemoveTSDictionaryById(Oid dictId);
 extern void AlterTSDictionary(AlterTSDictionaryStmt *stmt);
 extern void AlterTSDictionaryOwner(List *name, Oid newOwnerId);
-extern void AlterTSDictionaryNamespace(List *name, const char *newschema);
-extern Oid	AlterTSDictionaryNamespace_oid(Oid dictId, Oid newNspOid);
 
 extern void DefineTSTemplate(List *names, List *parameters);
 extern void RenameTSTemplate(List *oldname, const char *newname);
-extern void AlterTSTemplateNamespace(List *name, const char *newschema);
-extern Oid	AlterTSTemplateNamespace_oid(Oid tmplId, Oid newNspOid);
 extern void RemoveTSTemplateById(Oid tmplId);
 
 extern void DefineTSConfiguration(List *names, List *parameters);
@@ -139,8 +124,6 @@ extern void RenameTSConfiguration(List *oldname, const char *newname);
 extern void RemoveTSConfigurationById(Oid cfgId);
 extern void AlterTSConfiguration(AlterTSConfigurationStmt *stmt);
 extern void AlterTSConfigurationOwner(List *name, Oid newOwnerId);
-extern void AlterTSConfigurationNamespace(List *name, const char *newschema);
-extern Oid	AlterTSConfigurationNamespace_oid(Oid cfgId, Oid newNspOid);
 
 extern text *serialize_deflist(List *deflist);
 extern List *deserialize_deflist(Datum txt);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 6449eca..77d4167 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2125,7 +2125,6 @@ typedef struct AlterObjectSchemaStmt
 	RangeVar   *relation;		/* in case it's a table */
 	List	   *object;			/* in case it's some other object */
 	List	   *objarg;			/* argument types, if applicable */
-	char	   *addname;		/* additional name if needed */
 	char	   *newschema;		/* the new schema */
 } AlterObjectSchemaStmt;
 
diff --git a/src/test/regress/expected/alter_rename.out b/src/test/regress/expected/alter_rename.out
index 6688d50..7248b49 100644
--- a/src/test/regress/expected/alter_rename.out
+++ b/src/test/regress/expected/alter_rename.out
@@ -128,7 +128,7 @@ ERROR:  function testfunc_b(integer) already exists in schema "testschema_1"
 ALTER FUNCTION testfunc_b(int) SET SCHEMA testschema_2;	-- OK
 ALTER FUNCTION testfunc_a(int) RENAME TO testfunc_b;	-- OK
 ALTER FUNCTION testfunc_b(int) SET SCHEMA testschema_2;	-- fail
-ERROR:  function "testfunc_b" already exists in schema "testschema_2"
+ERROR:  function testfunc_b(integer) already exists in schema "testschema_2"
 CREATE AGGREGATE testagg_a(
 	   sfunc1 = int4pl, basetype = int4, stype1 = int4,
 	   initcond1 = '0'
@@ -142,7 +142,7 @@ ERROR:  function testagg_b(integer) already exists in schema "testschema_1"
 ALTER AGGREGATE testagg_b(int) SET SCHEMA testschema_2;	-- OK
 ALTER AGGREGATE testagg_a(int) RENAME TO testagg_b;		-- OK
 ALTER AGGREGATE testagg_b(int) SET SCHEMA testschema_2;	-- fail
-ERROR:  function "testagg_b" already exists in schema "testschema_2"
+ERROR:  function testagg_b(integer) already exists in schema "testschema_2"
 --
 -- TYPE
 --
@@ -172,16 +172,16 @@ CREATE OPERATOR @#@
 ALTER OPERATOR @#@(int8,int8) SET SCHEMA testschema_2;	-- OK
 CREATE OPERATOR @#@
 	   (leftarg = int8, rightarg = int8, procedure = int8xor);
--- XXX - comment out due to error message with oid determinded at runtime
--- ALTER OPERATOR @#@(int8,int8) SET SCHEMA testschema_2;	-- fail
+ALTER OPERATOR @#@(int8,int8) SET SCHEMA testschema_2;	-- fail
+ERROR:  operator @#@(bigint,bigint) already exists in schema "testschema_2"
 CREATE OPERATOR FAMILY testopfamily_a USING btree;
 CREATE OPERATOR FAMILY testopfamily_b USING btree;
 ALTER OPERATOR FAMILY testopfamily_a USING btree RENAME TO testopfamily_b;	-- fail
 ERROR:  operator family "testopfamily_b" for access method "btree" already exists in schema "testschema_1"
 ALTER OPERATOR FAMILY testopfamily_b USING btree SET SCHEMA testschema_2;	-- OK
 ALTER OPERATOR FAMILY testopfamily_a USING btree RENAME TO testopfamily_b;	-- OK
--- XXX - comment out due to error message with oid determinded at runtime
--- ALTER OPERATOR FAMILY testopfamily_b USING btree SET SCHEMA testschema_2;	-- fail
+ALTER OPERATOR FAMILY testopfamily_b USING btree SET SCHEMA testschema_2;	-- fail
+ERROR:  operator family testopfamily_b for access method btree already exists in schema "testschema_2"
 CREATE OPERATOR CLASS testopclass_a
 	   FOR TYPE box USING btree FAMILY testopfamily_b AS OPERATOR 1 =;
 CREATE OPERATOR CLASS testopclass_b
@@ -190,8 +190,8 @@ ALTER OPERATOR CLASS testopclass_a USING btree RENAME TO testopclass_b;		-- fail
 ERROR:  operator class "testopclass_b" for access method "btree" already exists in schema "testschema_1"
 ALTER OPERATOR CLASS testopclass_b USING btree SET SCHEMA testschema_2;		-- OK
 ALTER OPERATOR CLASS testopclass_a USING btree RENAME TO testopclass_b;		-- OK
--- XXX - comment out due to error message with oid determinded at runtime
--- ALTER OPERATOR CLASS testopclass_b USING btree SET SCHEMA testschema_2;		-- fail
+ALTER OPERATOR CLASS testopclass_b USING btree SET SCHEMA testschema_2;		-- fail
+ERROR:  operator class testopclass_b for access method btree already exists in schema "testschema_2"
 --
 -- TEXT SEARCH
 --
@@ -229,7 +229,7 @@ ERROR:  collation "testcollation_b" for encoding "UTF8" already exists in schema
 ALTER COLLATION testcollation_b SET SCHEMA testschema_2;	-- OK
 ALTER COLLATION testcollation_a RENAME TO testcollation_b;	-- OK
 ALTER COLLATION testcollation_b SET SCHEMA testschema_2;	-- fail
-ERROR:  collation "testcollation_b" for encoding "UTF8" already exists in schema "testschema_2"
+ERROR:  collation testcollation_b already exists in schema "testschema_2"
 --
 -- CONVERSION
 --
diff --git a/src/test/regress/sql/alter_rename.sql b/src/test/regress/sql/alter_rename.sql
index 9b2bdf1..4a33b12 100644
--- a/src/test/regress/sql/alter_rename.sql
+++ b/src/test/regress/sql/alter_rename.sql
@@ -162,16 +162,14 @@ CREATE OPERATOR @#@
 ALTER OPERATOR @#@(int8,int8) SET SCHEMA testschema_2;	-- OK
 CREATE OPERATOR @#@
 	   (leftarg = int8, rightarg = int8, procedure = int8xor);
--- XXX - comment out due to error message with oid determinded at runtime
--- ALTER OPERATOR @#@(int8,int8) SET SCHEMA testschema_2;	-- fail
+ALTER OPERATOR @#@(int8,int8) SET SCHEMA testschema_2;	-- fail
 
 CREATE OPERATOR FAMILY testopfamily_a USING btree;
 CREATE OPERATOR FAMILY testopfamily_b USING btree;
 ALTER OPERATOR FAMILY testopfamily_a USING btree RENAME TO testopfamily_b;	-- fail
 ALTER OPERATOR FAMILY testopfamily_b USING btree SET SCHEMA testschema_2;	-- OK
 ALTER OPERATOR FAMILY testopfamily_a USING btree RENAME TO testopfamily_b;	-- OK
--- XXX - comment out due to error message with oid determinded at runtime
--- ALTER OPERATOR FAMILY testopfamily_b USING btree SET SCHEMA testschema_2;	-- fail
+ALTER OPERATOR FAMILY testopfamily_b USING btree SET SCHEMA testschema_2;	-- fail
 
 
 CREATE OPERATOR CLASS testopclass_a
@@ -181,8 +179,7 @@ CREATE OPERATOR CLASS testopclass_b
 ALTER OPERATOR CLASS testopclass_a USING btree RENAME TO testopclass_b;		-- fail
 ALTER OPERATOR CLASS testopclass_b USING btree SET SCHEMA testschema_2;		-- OK
 ALTER OPERATOR CLASS testopclass_a USING btree RENAME TO testopclass_b;		-- OK
--- XXX - comment out due to error message with oid determinded at runtime
--- ALTER OPERATOR CLASS testopclass_b USING btree SET SCHEMA testschema_2;		-- fail
+ALTER OPERATOR CLASS testopclass_b USING btree SET SCHEMA testschema_2;		-- fail
 
 --
 -- TEXT SEARCH
