 src/backend/catalog/objectaddress.c         | 257 +++++++++++--
 src/backend/commands/alter.c                | 107 +++---
 src/backend/commands/conversioncmds.c       |  50 ---
 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         |  10 +
 src/include/commands/conversioncmds.h       |   2 -
 src/include/commands/defrem.h               |  14 -
 src/include/nodes/parsenodes.h              |   1 -
 src/test/regress/expected/alter_generic.out | 545 ++++++++++++++++++++++++++++
 src/test/regress/parallel_schedule          |   2 +-
 src/test/regress/serial_schedule            |   1 +
 src/test/regress/sql/alter_generic.sql      | 413 +++++++++++++++++++++
 17 files changed, 1258 insertions(+), 495 deletions(-)

diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index c1e5e1d..820a0db 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -81,7 +81,13 @@ typedef struct
 	Oid			class_oid;		/* oid of catalog */
 	Oid			oid_index_oid;	/* oid of index on system oid column */
 	int			oid_catcache_id;	/* id of catcache on system oid column	*/
+	int			name_catcache_id;	/* id of catcache on a pair of name and
+									 * namespace column */
+	AttrNumber	attnum_name;	/* attnum of name field */
 	AttrNumber	attnum_namespace;		/* attnum of namespace field */
+	AttrNumber	attnum_owner;	/* attnum of owner field */
+	AttrNumber	attnum_acl;		/* attnum of acl field */
+	AclObjectKind	acl_kind;	/* ACL_KIND_* of this object type */
 } ObjectPropertyType;
 
 static ObjectPropertyType ObjectProperty[] =
@@ -90,157 +96,287 @@ static ObjectPropertyType ObjectProperty[] =
 		CastRelationId,
 		CastOidIndexId,
 		-1,
-		InvalidAttrNumber
+		-1,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1
 	},
 	{
 		CollationRelationId,
 		CollationOidIndexId,
 		COLLOID,
-		Anum_pg_collation_collnamespace
+		-1,			/* COLLNAMEENCNSP also takes encoding */
+		Anum_pg_collation_collname,
+		Anum_pg_collation_collnamespace,
+		Anum_pg_collation_collowner,
+		InvalidAttrNumber,
+		ACL_KIND_COLLATION
 	},
 	{
 		ConstraintRelationId,
 		ConstraintOidIndexId,
 		CONSTROID,
-		Anum_pg_constraint_connamespace
+		-1,
+		Anum_pg_constraint_conname,
+		Anum_pg_constraint_connamespace,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1
 	},
 	{
 		ConversionRelationId,
 		ConversionOidIndexId,
 		CONVOID,
-		Anum_pg_conversion_connamespace
+		CONNAMENSP,
+		Anum_pg_conversion_conname,
+		Anum_pg_conversion_connamespace,
+		Anum_pg_conversion_conowner,
+		InvalidAttrNumber,
+		ACL_KIND_CONVERSION
 	},
 	{
 		DatabaseRelationId,
 		DatabaseOidIndexId,
 		DATABASEOID,
-		InvalidAttrNumber
+		-1,
+		Anum_pg_database_datname,
+		InvalidAttrNumber,
+		Anum_pg_database_datdba,
+		Anum_pg_database_datacl,
+		ACL_KIND_DATABASE
 	},
 	{
 		ExtensionRelationId,
 		ExtensionOidIndexId,
 		-1,
-		InvalidAttrNumber		/* extension doesn't belong to extnamespace */
+		-1,
+		Anum_pg_extension_extname,
+		InvalidAttrNumber,		/* extension doesn't belong to extnamespace */
+		Anum_pg_extension_extowner,
+		InvalidAttrNumber,
+		ACL_KIND_EXTENSION
 	},
 	{
 		ForeignDataWrapperRelationId,
 		ForeignDataWrapperOidIndexId,
 		FOREIGNDATAWRAPPEROID,
-		InvalidAttrNumber
+		FOREIGNDATAWRAPPERNAME,
+		Anum_pg_foreign_data_wrapper_fdwname,
+		InvalidAttrNumber,
+		Anum_pg_foreign_data_wrapper_fdwowner,
+		Anum_pg_foreign_data_wrapper_fdwacl,
+		ACL_KIND_FDW
 	},
 	{
 		ForeignServerRelationId,
 		ForeignServerOidIndexId,
 		FOREIGNSERVEROID,
-		InvalidAttrNumber
+		FOREIGNSERVERNAME,
+		Anum_pg_foreign_server_srvname,
+		InvalidAttrNumber,
+		Anum_pg_foreign_server_srvowner,
+		Anum_pg_foreign_server_srvacl,
+		ACL_KIND_FOREIGN_SERVER
 	},
 	{
 		ProcedureRelationId,
 		ProcedureOidIndexId,
 		PROCOID,
-		Anum_pg_proc_pronamespace
+		-1,			/* PROCNAMEARGSNSP also takes argument types */
+		Anum_pg_proc_proname,
+		Anum_pg_proc_pronamespace,
+		Anum_pg_proc_proowner,
+		Anum_pg_proc_proacl,
+		ACL_KIND_PROC
 	},
 	{
 		LanguageRelationId,
 		LanguageOidIndexId,
 		LANGOID,
+		LANGNAME,
+		Anum_pg_language_lanname,
 		InvalidAttrNumber,
+		Anum_pg_language_lanowner,
+		Anum_pg_language_lanacl,
+		ACL_KIND_LANGUAGE
 	},
 	{
 		LargeObjectMetadataRelationId,
 		LargeObjectMetadataOidIndexId,
 		-1,
-		InvalidAttrNumber
+		-1,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		Anum_pg_largeobject_metadata_lomowner,
+		Anum_pg_largeobject_metadata_lomacl,
+		ACL_KIND_LARGEOBJECT
 	},
 	{
 		OperatorClassRelationId,
 		OpclassOidIndexId,
 		CLAOID,
+		-1,			/* CLAAMNAMENSP also takes opcmethod */
+		Anum_pg_opclass_opcname,
 		Anum_pg_opclass_opcnamespace,
+		Anum_pg_opclass_opcowner,
+		InvalidAttrNumber,
+		ACL_KIND_OPCLASS
 	},
 	{
 		OperatorRelationId,
 		OperatorOidIndexId,
 		OPEROID,
-		Anum_pg_operator_oprnamespace
+		-1,			/* OPERNAMENSP also takes left and right type */
+		Anum_pg_operator_oprname,
+		Anum_pg_operator_oprnamespace,
+		Anum_pg_operator_oprowner,
+		InvalidAttrNumber,
+		ACL_KIND_OPER
 	},
 	{
 		OperatorFamilyRelationId,
 		OpfamilyOidIndexId,
 		OPFAMILYOID,
-		Anum_pg_opfamily_opfnamespace
+		-1,			/* OPFAMILYAMNAMENSP also takes opfmethod */
+		Anum_pg_opfamily_opfname,
+		Anum_pg_opfamily_opfnamespace,
+		Anum_pg_opfamily_opfowner,
+		InvalidAttrNumber,
+		ACL_KIND_OPFAMILY
 	},
 	{
 		AuthIdRelationId,
 		AuthIdOidIndexId,
 		AUTHOID,
-		InvalidAttrNumber
+		AUTHNAME,
+		Anum_pg_authid_rolname,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1
 	},
 	{
 		RewriteRelationId,
 		RewriteOidIndexId,
 		-1,
-		InvalidAttrNumber
+		-1,
+		Anum_pg_rewrite_rulename,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1
 	},
 	{
 		NamespaceRelationId,
 		NamespaceOidIndexId,
 		NAMESPACEOID,
-		InvalidAttrNumber
+		NAMESPACENAME,
+		Anum_pg_namespace_nspname,
+		InvalidAttrNumber,
+		Anum_pg_namespace_nspowner,
+		Anum_pg_namespace_nspacl,
+		ACL_KIND_NAMESPACE
 	},
 	{
 		RelationRelationId,
 		ClassOidIndexId,
 		RELOID,
-		Anum_pg_class_relnamespace
+		RELNAMENSP,
+		Anum_pg_class_relname,
+		Anum_pg_class_relnamespace,
+		Anum_pg_class_relowner,
+		Anum_pg_class_relacl,
+		ACL_KIND_CLASS
 	},
 	{
 		TableSpaceRelationId,
 		TablespaceOidIndexId,
 		TABLESPACEOID,
-		InvalidAttrNumber
+		-1,
+		Anum_pg_tablespace_spcname,
+		InvalidAttrNumber,
+		Anum_pg_tablespace_spcowner,
+		Anum_pg_tablespace_spcacl,
+		ACL_KIND_TABLESPACE
 	},
 	{
 		TriggerRelationId,
 		TriggerOidIndexId,
 		-1,
-		InvalidAttrNumber
+		-1,
+		Anum_pg_trigger_tgname,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1,
 	},
 	{
 		EventTriggerRelationId,
 		EventTriggerOidIndexId,
-		-1,
-		InvalidAttrNumber
+		EVENTTRIGGEROID,
+		EVENTTRIGGERNAME,
+		Anum_pg_event_trigger_evtname,
+		InvalidAttrNumber,
+		Anum_pg_event_trigger_evtowner,
+		InvalidAttrNumber,
+		ACL_KIND_EVENT_TRIGGER,
 	},
 	{
 		TSConfigRelationId,
 		TSConfigOidIndexId,
 		TSCONFIGOID,
-		Anum_pg_ts_config_cfgnamespace
+		TSCONFIGNAMENSP,
+		Anum_pg_ts_config_cfgname,
+		Anum_pg_ts_config_cfgnamespace,
+		Anum_pg_ts_config_cfgowner,
+		InvalidAttrNumber,
+		ACL_KIND_TSCONFIGURATION
 	},
 	{
 		TSDictionaryRelationId,
 		TSDictionaryOidIndexId,
 		TSDICTOID,
-		Anum_pg_ts_dict_dictnamespace
+		TSDICTNAMENSP,
+		Anum_pg_ts_dict_dictname,
+		Anum_pg_ts_dict_dictnamespace,
+		Anum_pg_ts_dict_dictowner,
+		InvalidAttrNumber,
+		ACL_KIND_TSDICTIONARY
 	},
 	{
 		TSParserRelationId,
 		TSParserOidIndexId,
 		TSPARSEROID,
-		Anum_pg_ts_parser_prsnamespace
+		TSPARSERNAMENSP,
+		Anum_pg_ts_parser_prsname,
+		Anum_pg_ts_parser_prsnamespace,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1,
 	},
 	{
 		TSTemplateRelationId,
 		TSTemplateOidIndexId,
 		TSTEMPLATEOID,
+		TSTEMPLATENAMENSP,
+		Anum_pg_ts_template_tmplname,
 		Anum_pg_ts_template_tmplnamespace,
+		InvalidAttrNumber,
+		InvalidAttrNumber,
+		-1,
 	},
 	{
 		TypeRelationId,
 		TypeOidIndexId,
 		TYPEOID,
-		Anum_pg_type_typnamespace
+		TYPENAMENSP,
+		Anum_pg_type_typname,
+		Anum_pg_type_typnamespace,
+		Anum_pg_type_typowner,
+		Anum_pg_type_typacl,
+		ACL_KIND_TYPE
 	}
 };
 
@@ -1133,17 +1269,88 @@ get_object_namespace(const ObjectAddress *address)
 }
 
 /*
+ * Interfaces to reference fields of ObjectPropertyType
+ */
+Oid
+get_object_oid_index(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->oid_index_oid;
+}
+
+int
+get_object_catcache_oid(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->oid_catcache_id;
+}
+
+int
+get_object_catcache_name(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->name_catcache_id;
+}
+
+AttrNumber
+get_object_attnum_name(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->attnum_name;
+}
+
+AttrNumber
+get_object_attnum_namespace(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->attnum_namespace;
+}
+
+AttrNumber
+get_object_attnum_owner(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->attnum_owner;
+}
+
+AttrNumber
+get_object_attnum_acl(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->attnum_acl;
+}
+
+AclObjectKind
+get_object_aclkind(Oid class_id)
+{
+	ObjectPropertyType *prop = get_object_property_data(class_id);
+	return prop->acl_kind;
+}
+
+/*
  * Find ObjectProperty structure by class_id.
  */
 static ObjectPropertyType *
 get_object_property_data(Oid class_id)
 {
+	static ObjectPropertyType  *prop_last = NULL;
 	int			index;
 
+	/*
+	 * A shortcut when caller want to know multiple attribute number
+	 * towards a particular object class.
+	 */
+	if (prop_last && prop_last->class_oid == class_id)
+		return prop_last;
+
 	for (index = 0; index < lengthof(ObjectProperty); index++)
+	{
 		if (ObjectProperty[index].class_oid == class_id)
+		{
+			prop_last = &ObjectProperty[index];
 			return &ObjectProperty[index];
-
+		}
+	}
 	elog(ERROR, "unrecognized class id: %u", class_id);
 	return NULL;				/* not reached */
 }
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index e5b813d..0d3c9ea 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -173,10 +173,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
 			AlterCollationNamespace(stmt->object, stmt->newschema);
 			break;
 
-		case OBJECT_CONVERSION:
-			AlterConversionNamespace(stmt->object, stmt->newschema);
-			break;
-
 		case OBJECT_EXTENSION:
 			AlterExtensionNamespace(stmt->object, stmt->newschema);
 			break;
@@ -186,18 +182,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
 								   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:
@@ -205,25 +189,49 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
 			AlterTableNamespace(stmt);
 			break;
 
-		case OBJECT_TSPARSER:
-			AlterTSParserNamespace(stmt->object, stmt->newschema);
-			break;
-
-		case OBJECT_TSDICTIONARY:
-			AlterTSDictionaryNamespace(stmt->object, stmt->newschema);
+		case OBJECT_TYPE:
+		case OBJECT_DOMAIN:
+			AlterTypeNamespace(stmt->object, stmt->newschema, stmt->objectType);
 			break;
 
+			/* generic code path */
+		case OBJECT_CONVERSION:
+		case OBJECT_OPERATOR:
+		case OBJECT_OPCLASS:
+		case OBJECT_OPFAMILY:
+		case OBJECT_TSPARSER:
+        case OBJECT_TSDICTIONARY:
 		case OBJECT_TSTEMPLATE:
-			AlterTSTemplateNamespace(stmt->object, stmt->newschema);
-			break;
-
 		case OBJECT_TSCONFIGURATION:
-			AlterTSConfigurationNamespace(stmt->object, stmt->newschema);
-			break;
-
-		case OBJECT_TYPE:
-		case OBJECT_DOMAIN:
-			AlterTypeNamespace(stmt->object, stmt->newschema, stmt->objectType);
+			{
+				Relation	catalog;
+				Relation	relation;
+				Oid			classId;
+				Oid			nspOid;
+				ObjectAddress	address;
+
+				address = get_object_address(stmt->objectType,
+											 stmt->object,
+											 stmt->objarg,
+											 &relation,
+											 AccessExclusiveLock,
+											 false);
+				classId = address.classId;
+				catalog = heap_open(classId, RowExclusiveLock);
+				nspOid = LookupCreationNamespace(stmt->newschema);
+
+				AlterObjectNamespace(catalog,
+									 get_object_catcache_oid(classId),
+									 get_object_catcache_name(classId),
+									 address.objectId, nspOid,
+									 get_object_attnum_name(classId),
+									 get_object_attnum_namespace(classId),
+									 get_object_attnum_owner(classId),
+									 get_object_aclkind(classId));
+				heap_close(catalog, RowExclusiveLock);
+				if (relation)
+					heap_close(relation, NoLock);
+			}
 			break;
 
 		default:
@@ -293,35 +301,28 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid 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);
+			{
+				Relation	catalog;
+
+				catalog = heap_open(classId, RowExclusiveLock);
+
+				AlterObjectNamespace(catalog,
+									 get_object_catcache_oid(classId),
+									 get_object_catcache_name(classId),
+									 objid, nspOid,
+									 get_object_attnum_name(classId),
+									 get_object_attnum_namespace(classId),
+									 get_object_attnum_owner(classId),
+									 get_object_aclkind(classId));
+				heap_close(catalog, RowExclusiveLock);
+			}
 			break;
 
 		default:
diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
index e36c91a..af690b8 100644
--- a/src/backend/commands/conversioncmds.c
+++ b/src/backend/commands/conversioncmds.c
@@ -266,53 +266,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/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 7cf4db0..e26c947 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -1915,58 +1915,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
@@ -2122,55 +2070,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 e0ac0e1..0d8dbe4 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -423,56 +423,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 487c7fb..8d2b4c0 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -346,52 +346,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 -----------------------*/
 
 /*
@@ -626,54 +580,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
@@ -1091,52 +997,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
@@ -1483,54 +1343,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 f34f704..f5a0aaf 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2932,7 +2932,6 @@ _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
 	COPY_NODE_FIELD(relation);
 	COPY_NODE_FIELD(object);
 	COPY_NODE_FIELD(objarg);
-	COPY_STRING_FIELD(addname);
 	COPY_STRING_FIELD(newschema);
 	COPY_SCALAR_FIELD(missing_ok);
 
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index b4b1c22..3fad36e 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1336,7 +1336,6 @@ _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSch
 	COMPARE_NODE_FIELD(relation);
 	COMPARE_NODE_FIELD(object);
 	COMPARE_NODE_FIELD(objarg);
-	COMPARE_STRING_FIELD(addname);
 	COMPARE_STRING_FIELD(newschema);
 	COMPARE_SCALAR_FIELD(missing_ok);
 
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 5894cb0..7d2ec84 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -7139,7 +7139,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;
 					n->missing_ok = false;
 					$$ = (Node *)n;
@@ -7149,7 +7149,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;
 					n->missing_ok = false;
 					$$ = (Node *)n;
diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
index 0af09c6..03514ac 100644
--- a/src/include/catalog/objectaddress.h
+++ b/src/include/catalog/objectaddress.h
@@ -15,6 +15,7 @@
 
 #include "nodes/parsenodes.h"
 #include "storage/lock.h"
+#include "utils/acl.h"
 #include "utils/relcache.h"
 
 /*
@@ -37,4 +38,13 @@ extern void check_object_ownership(Oid roleid,
 
 extern Oid	get_object_namespace(const ObjectAddress *address);
 
+extern Oid				get_object_oid_index(Oid class_id);
+extern int				get_object_catcache_oid(Oid class_id);
+extern int				get_object_catcache_name(Oid class_id);
+extern AttrNumber		get_object_attnum_name(Oid class_id);
+extern AttrNumber		get_object_attnum_namespace(Oid class_id);
+extern AttrNumber		get_object_attnum_owner(Oid class_id);
+extern AttrNumber		get_object_attnum_acl(Oid class_id);
+extern AclObjectKind	get_object_aclkind(Oid class_id);
+
 #endif   /* PARSE_OBJECT_H */
diff --git a/src/include/commands/conversioncmds.h b/src/include/commands/conversioncmds.h
index 00f468f..778161b 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 9b6d57a..300f7ea 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -64,8 +64,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,
@@ -85,12 +83,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);
@@ -98,8 +92,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);
@@ -107,13 +99,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);
@@ -121,8 +109,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 19178b5..201d366 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2168,7 +2168,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 */
 	bool		missing_ok;		/* skip error if missing? */
 } AlterObjectSchemaStmt;
diff --git a/src/test/regress/expected/alter_generic.out b/src/test/regress/expected/alter_generic.out
new file mode 100644
index 0000000..002f557
--- /dev/null
+++ b/src/test/regress/expected/alter_generic.out
@@ -0,0 +1,545 @@
+--
+-- Test for ALTER RENAME TO/OWNER TO/SET SCHEMA
+--
+-- Clean up in case a prior regression run failed
+SET client_min_messages TO 'warning';
+DROP ROLE IF EXISTS regtest_alter_user1;
+DROP ROLE IF EXISTS regtest_alter_user2;
+DROP ROLE IF EXISTS regtest_alter_user3;
+RESET client_min_messages;
+CREATE USER regtest_alter_user3;
+CREATE USER regtest_alter_user2;
+CREATE USER regtest_alter_user1 IN ROLE regtest_alter_user3;
+CREATE SCHEMA alt_nsp1;
+CREATE SCHEMA alt_nsp2;
+GRANT ALL ON SCHEMA alt_nsp1, alt_nsp2 TO public;
+SET search_path = alt_nsp1, public;
+--
+-- Function and Aggregate
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 + 1';
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 - 1';
+CREATE AGGREGATE alt_agg1 (
+  sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
+);
+CREATE AGGREGATE alt_agg2 (
+  sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = 0
+);
+ALTER AGGREGATE alt_func1(int) RENAME TO alt_func3;  -- failed (not aggregate)
+ERROR:  function alt_func1(integer) is not an aggregate
+ALTER AGGREGATE alt_func1(int) OWNER TO regtest_alter_user3;  -- failed (not aggregate)
+ERROR:  function alt_func1(integer) is not an aggregate
+ALTER AGGREGATE alt_func1(int) SET SCHEMA alt_nsp2;  -- failed (not aggregate)
+ERROR:  function alt_func1(integer) is not an aggregate
+ALTER FUNCTION alt_func1(int) RENAME TO alt_func2;  -- failed (name conflict)
+ERROR:  function alt_func2(integer) already exists in schema "alt_nsp1"
+ALTER FUNCTION alt_func1(int) RENAME TO alt_func3;  -- OK
+ALTER FUNCTION alt_func2(int) OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER FUNCTION alt_func2(int) OWNER TO regtest_alter_user3;  -- OK
+ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2;  -- OK
+ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg2;   -- failed (name conflict)
+ERROR:  function alt_agg2(integer) already exists in schema "alt_nsp1"
+ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg3;   -- OK
+ALTER AGGREGATE alt_agg2(int) OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER AGGREGATE alt_agg2(int) OWNER TO regtest_alter_user3;  -- OK
+ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2;  -- OK
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 + 2';
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 - 2';
+CREATE AGGREGATE alt_agg1 (
+  sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
+);
+CREATE AGGREGATE alt_agg2 (
+  sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = -100
+);
+ALTER FUNCTION alt_func3(int) RENAME TO alt_func4;	-- failed (not owner)
+ERROR:  must be owner of function alt_func3
+ALTER FUNCTION alt_func1(int) RENAME TO alt_func4;	-- OK
+ALTER FUNCTION alt_func3(int) OWNER TO regtest_alter_user2;	-- failed (not owner)
+ERROR:  must be owner of function alt_func3
+ALTER FUNCTION alt_func2(int) OWNER TO regtest_alter_user3;	-- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER FUNCTION alt_func3(int) SET SCHEMA alt_nsp2;      -- failed (not owner)
+ERROR:  must be owner of function alt_func3
+ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2;	-- failed (name conflicts)
+ERROR:  function "alt_func2" already exists in schema "alt_nsp2"
+ALTER AGGREGATE alt_agg3(int) RENAME TO alt_agg4;   -- failed (not owner)
+ERROR:  must be owner of function alt_agg3
+ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg4;   -- OK
+ALTER AGGREGATE alt_agg3(int) OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of function alt_agg3
+ALTER AGGREGATE alt_agg2(int) OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER AGGREGATE alt_agg3(int) SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of function alt_agg3
+ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2;  -- failed (name conflict)
+ERROR:  function "alt_agg2" already exists in schema "alt_nsp2"
+RESET SESSION AUTHORIZATION;
+SELECT n.nspname, proname, prorettype::regtype, proisagg, a.rolname
+  FROM pg_proc p, pg_namespace n, pg_authid a
+  WHERE p.pronamespace = n.oid AND p.proowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, proname;
+ nspname  |  proname  | prorettype | proisagg |       rolname       
+----------+-----------+------------+----------+---------------------
+ alt_nsp1 | alt_agg2  | integer    | t        | regtest_alter_user2
+ alt_nsp1 | alt_agg3  | integer    | t        | regtest_alter_user1
+ alt_nsp1 | alt_agg4  | integer    | t        | regtest_alter_user2
+ alt_nsp1 | alt_func2 | integer    | f        | regtest_alter_user2
+ alt_nsp1 | alt_func3 | integer    | f        | regtest_alter_user1
+ alt_nsp1 | alt_func4 | integer    | f        | regtest_alter_user2
+ alt_nsp2 | alt_agg2  | integer    | t        | regtest_alter_user3
+ alt_nsp2 | alt_func2 | integer    | f        | regtest_alter_user3
+(8 rows)
+
+--
+-- Collation
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE COLLATION alt_coll1 (locale = 'C');
+CREATE COLLATION alt_coll2 (locale = 'C');
+ALTER COLLATION alt_coll1 RENAME TO alt_coll2;  -- failed (name conflict)
+ERROR:  collation "alt_coll2" for encoding "SQL_ASCII" already exists in schema "alt_nsp1"
+ALTER COLLATION alt_coll1 RENAME TO alt_coll3;  -- OK
+ALTER COLLATION alt_coll2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER COLLATION alt_coll2 OWNER TO regtest_alter_user3;  -- OK
+ALTER COLLATION alt_coll2 SET SCHEMA alt_nsp2;  -- OK
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE COLLATION alt_coll1 (locale = 'C');
+CREATE COLLATION alt_coll2 (locale = 'C');
+ALTER COLLATION alt_coll3 RENAME TO alt_coll4;  -- failed (not owner)
+ERROR:  must be owner of collation alt_coll3
+ALTER COLLATION alt_coll1 RENAME TO alt_coll4;  -- OK
+ALTER COLLATION alt_coll3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of collation alt_coll3
+ALTER COLLATION alt_coll2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER COLLATION alt_coll3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of collation alt_coll3
+ALTER COLLATION alt_coll2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+ERROR:  collation "alt_coll2" for encoding "SQL_ASCII" already exists in schema "alt_nsp2"
+RESET SESSION AUTHORIZATION;
+SELECT n.nspname, c.collname, a.rolname
+  FROM pg_collation c, pg_namespace n, pg_authid a
+  WHERE c.collnamespace = n.oid AND c.collowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY n.nspname, c.collname;
+ nspname  | collname  |       rolname       
+----------+-----------+---------------------
+ alt_nsp1 | alt_coll2 | regtest_alter_user2
+ alt_nsp1 | alt_coll3 | regtest_alter_user1
+ alt_nsp1 | alt_coll4 | regtest_alter_user2
+ alt_nsp2 | alt_coll2 | regtest_alter_user3
+(4 rows)
+
+--
+-- Conversion
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+ALTER CONVERSION alt_conv1 RENAME TO alt_conv2;  -- failed (name conflict)
+ERROR:  conversion "alt_conv2" already exists in schema "alt_nsp1"
+ALTER CONVERSION alt_conv1 RENAME TO alt_conv3;  -- OK
+ALTER CONVERSION alt_conv2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER CONVERSION alt_conv2 OWNER TO regtest_alter_user3;  -- OK
+ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2;  -- OK
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+ALTER CONVERSION alt_conv3 RENAME TO alt_conv4;  -- failed (not owner)
+ERROR:  must be owner of conversion alt_conv3
+ALTER CONVERSION alt_conv1 RENAME TO alt_conv4;  -- OK
+ALTER CONVERSION alt_conv3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of conversion alt_conv3
+ALTER CONVERSION alt_conv2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER CONVERSION alt_conv3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of conversion alt_conv3
+ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+ERROR:  conversion alt_conv2 already exists in schema "alt_nsp2"
+RESET SESSION AUTHORIZATION;
+SELECT n.nspname, c.conname, a.rolname
+  FROM pg_conversion c, pg_namespace n, pg_authid a
+  WHERE c.connamespace = n.oid AND c.conowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, conname;
+ nspname  |  conname  |       rolname       
+----------+-----------+---------------------
+ alt_nsp1 | alt_conv2 | regtest_alter_user2
+ alt_nsp1 | alt_conv3 | regtest_alter_user1
+ alt_nsp1 | alt_conv4 | regtest_alter_user2
+ alt_nsp2 | alt_conv2 | regtest_alter_user3
+(4 rows)
+
+--
+-- Foreign Data Wrapper and Foreign Server
+--
+CREATE FOREIGN DATA WRAPPER alt_fdw1;
+CREATE FOREIGN DATA WRAPPER alt_fdw2;
+CREATE SERVER alt_fserv1 FOREIGN DATA WRAPPER alt_fdw1;
+CREATE SERVER alt_fserv2 FOREIGN DATA WRAPPER alt_fdw2;
+ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw2;  -- failed (name conflict)
+ERROR:  foreign-data wrapper "alt_fdw2" already exists
+ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw3;  -- OK
+ALTER SERVER alt_fserv1 RENAME TO alt_fserv2;   -- failed (name conflict)
+ERROR:  server "alt_fserv2" already exists
+ALTER SERVER alt_fserv1 RENAME TO alt_fserv3;   -- OK
+SELECT fdwname FROM pg_foreign_data_wrapper WHERE fdwname like 'alt_fdw%';
+ fdwname  
+----------
+ alt_fdw2
+ alt_fdw3
+(2 rows)
+
+SELECT srvname FROM pg_foreign_server WHERE srvname like 'alt_fserv%';
+  srvname   
+------------
+ alt_fserv2
+ alt_fserv3
+(2 rows)
+
+--
+-- Procedural Language
+--
+CREATE LANGUAGE alt_lang1 HANDLER plpgsql_call_handler;
+CREATE LANGUAGE alt_lang2 HANDLER plpgsql_call_handler;
+ALTER LANGUAGE alt_lang1 OWNER TO regtest_alter_user1;  -- OK
+ALTER LANGUAGE alt_lang2 OWNER TO regtest_alter_user2;  -- OK
+SET SESSION AUTHORIZATION regtest_alter_user1;
+ALTER LANGUAGE alt_lang1 RENAME TO alt_lang2;   -- failed (name conflict)
+ERROR:  language "alt_lang2" already exists
+ALTER LANGUAGE alt_lang2 RENAME TO alt_lang3;   -- failed (not owner)
+ERROR:  must be owner of language alt_lang2
+ALTER LANGUAGE alt_lang1 RENAME TO alt_lang3;   -- OK
+ALTER LANGUAGE alt_lang2 OWNER TO regtest_alter_user3;  -- failed (not owner)
+ERROR:  must be owner of language alt_lang2
+ALTER LANGUAGE alt_lang3 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER LANGUAGE alt_lang3 OWNER TO regtest_alter_user3;  -- OK
+RESET SESSION AUTHORIZATION;
+SELECT lanname, a.rolname
+  FROM pg_language l, pg_authid a
+  WHERE l.lanowner = a.oid AND l.lanname like 'alt_lang%'
+  ORDER BY lanname;
+  lanname  |       rolname       
+-----------+---------------------
+ alt_lang2 | regtest_alter_user2
+ alt_lang3 | regtest_alter_user3
+(2 rows)
+
+--
+-- Operator
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi );
+CREATE OPERATOR @+@ ( leftarg = int4, rightarg = int4, procedure = int4pl );
+ALTER OPERATOR @+@(int4, int4) OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER OPERATOR @+@(int4, int4) OWNER TO regtest_alter_user3;  -- OK
+ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2;           -- OK
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi );
+ALTER OPERATOR @+@(int4, int4) OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of operator @+@
+ALTER OPERATOR @-@(int4, int4) OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER OPERATOR @+@(int4, int4) SET SCHEMA alt_nsp2;   -- failed (not owner)
+ERROR:  must be owner of operator @+@
+-- ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2;   -- failed (name conflict)
+-- XXX it raises raw oid of namespace, it makes unneeded regression test fail...
+RESET SESSION AUTHORIZATION;
+SELECT n.nspname, oprname, a.rolname, oprleft::regtype, oprright::regtype, oprcode::regproc
+  FROM pg_operator o, pg_namespace n, pg_authid a
+  WHERE o.oprnamespace = n.oid AND o.oprowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, oprname;
+ nspname  | oprname |       rolname       | oprleft | oprright | oprcode 
+----------+---------+---------------------+---------+----------+---------
+ alt_nsp1 | @+@     | regtest_alter_user3 | integer | integer  | int4pl
+ alt_nsp1 | @-@     | regtest_alter_user2 | integer | integer  | int4mi
+ alt_nsp2 | @-@     | regtest_alter_user1 | integer | integer  | int4mi
+(3 rows)
+
+--
+-- OpFamily and OpClass
+--
+CREATE OPERATOR FAMILY alt_opf1 USING hash;
+CREATE OPERATOR FAMILY alt_opf2 USING hash;
+ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regtest_alter_user1;
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user1;
+CREATE OPERATOR CLASS alt_opc1 FOR TYPE uuid USING hash AS STORAGE uuid;
+CREATE OPERATOR CLASS alt_opc2 FOR TYPE uuid USING hash AS STORAGE uuid;
+ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regtest_alter_user1;
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user1;
+SET SESSION AUTHORIZATION regtest_alter_user1;
+ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf2;  -- failed (name conflict)
+ERROR:  operator family "alt_opf2" for access method "hash" already exists in schema "alt_nsp1"
+ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf3;  -- OK
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user3;  -- OK
+ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2;  -- OK
+ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc2;  -- failed (name conflict)
+ERROR:  operator class "alt_opc2" for access method "hash" already exists in schema "alt_nsp1"
+ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc3;  -- OK
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user3;  -- OK
+ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2;  -- OK
+RESET SESSION AUTHORIZATION;
+CREATE OPERATOR FAMILY alt_opf1 USING hash;
+CREATE OPERATOR FAMILY alt_opf2 USING hash;
+ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regtest_alter_user2;
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user2;
+CREATE OPERATOR CLASS alt_opc1 FOR TYPE macaddr USING hash AS STORAGE macaddr;
+CREATE OPERATOR CLASS alt_opc2 FOR TYPE macaddr USING hash AS STORAGE macaddr;
+ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regtest_alter_user2;
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user2;
+SET SESSION AUTHORIZATION regtest_alter_user2;
+ALTER OPERATOR FAMILY alt_opf3 USING hash RENAME TO alt_opf4;	-- failed (not owner)
+ERROR:  must be owner of operator family alt_opf3
+ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf4;  -- OK
+ALTER OPERATOR FAMILY alt_opf3 USING hash OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of operator family alt_opf3
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER OPERATOR FAMILY alt_opf3 USING hash SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of operator family alt_opf3
+-- ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2;  -- failed (name conflict)
+ALTER OPERATOR CLASS alt_opc3 USING hash RENAME TO alt_opc4;	-- failed (not owner)
+ERROR:  must be owner of operator class alt_opc3
+ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc4;  -- OK
+ALTER OPERATOR CLASS alt_opc3 USING hash OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of operator class alt_opc3
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER OPERATOR CLASS alt_opc3 USING hash SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of operator class alt_opc3
+-- ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2;  -- failed (name conflict)
+RESET SESSION AUTHORIZATION;
+SELECT nspname, opfname, amname, rolname
+  FROM pg_opfamily o, pg_am m, pg_namespace n, pg_authid a
+  WHERE o.opfmethod = m.oid AND o.opfnamespace = n.oid AND o.opfowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, opfname;
+ nspname  | opfname  | amname |       rolname       
+----------+----------+--------+---------------------
+ alt_nsp1 | alt_opc1 | hash   | kaigai
+ alt_nsp1 | alt_opc2 | hash   | kaigai
+ alt_nsp1 | alt_opf2 | hash   | regtest_alter_user2
+ alt_nsp1 | alt_opf3 | hash   | regtest_alter_user1
+ alt_nsp1 | alt_opf4 | hash   | regtest_alter_user2
+ alt_nsp2 | alt_opf2 | hash   | regtest_alter_user3
+(6 rows)
+
+SELECT nspname, opcname, amname, rolname
+  FROM pg_opclass o, pg_am m, pg_namespace n, pg_authid a
+  WHERE o.opcmethod = m.oid AND o.opcnamespace = n.oid AND o.opcowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, opcname;
+ nspname  | opcname  | amname |       rolname       
+----------+----------+--------+---------------------
+ alt_nsp1 | alt_opc2 | hash   | regtest_alter_user2
+ alt_nsp1 | alt_opc3 | hash   | regtest_alter_user1
+ alt_nsp1 | alt_opc4 | hash   | regtest_alter_user2
+ alt_nsp2 | alt_opc2 | hash   | regtest_alter_user3
+(4 rows)
+
+--
+-- Text Search Dictionary
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple);
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple);
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict2;  -- failed (name conflict)
+ERROR:  text search dictionary "alt_ts_dict2" already exists
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict3;  -- OK
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regtest_alter_user3;  -- OK
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2;  -- OK
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple);
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple);
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 RENAME TO alt_ts_dict4;  -- failed (not owner)
+ERROR:  must be owner of text search dictionary alt_ts_dict3
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict4;  -- OK
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of text search dictionary alt_ts_dict3
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of text search dictionary alt_ts_dict3
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+ERROR:  text search dictionary alt_ts_dict2 already exists in schema "alt_nsp2"
+RESET SESSION AUTHORIZATION;
+SELECT nspname, dictname, rolname
+  FROM pg_ts_dict t, pg_namespace n, pg_authid a
+  WHERE t.dictnamespace = n.oid AND t.dictowner = a.oid
+    AND n.nspname in ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, dictname;
+ nspname  |   dictname   |       rolname       
+----------+--------------+---------------------
+ alt_nsp1 | alt_ts_dict2 | regtest_alter_user2
+ alt_nsp1 | alt_ts_dict3 | regtest_alter_user1
+ alt_nsp1 | alt_ts_dict4 | regtest_alter_user2
+ alt_nsp2 | alt_ts_dict2 | regtest_alter_user3
+(4 rows)
+
+--
+-- Text Search Configuration
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english);
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english);
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf2;  -- failed (name conflict)
+ERROR:  text search configuration "alt_ts_conf2" already exists
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf3;  -- OK
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user2"
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regtest_alter_user3;  -- OK
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2;  -- OK
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english);
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english);
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 RENAME TO alt_ts_conf4;  -- failed (not owner)
+ERROR:  must be owner of text search configuration alt_ts_conf3
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf4;  -- OK
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ERROR:  must be owner of text search configuration alt_ts_conf3
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ERROR:  must be member of role "regtest_alter_user3"
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ERROR:  must be owner of text search configuration alt_ts_conf3
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+ERROR:  text search configuration alt_ts_conf2 already exists in schema "alt_nsp2"
+RESET SESSION AUTHORIZATION;
+SELECT nspname, cfgname, rolname
+  FROM pg_ts_config t, pg_namespace n, pg_authid a
+  WHERE t.cfgnamespace = n.oid AND t.cfgowner = a.oid
+    AND n.nspname in ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, cfgname;
+ nspname  |   cfgname    |       rolname       
+----------+--------------+---------------------
+ alt_nsp1 | alt_ts_conf2 | regtest_alter_user2
+ alt_nsp1 | alt_ts_conf3 | regtest_alter_user1
+ alt_nsp1 | alt_ts_conf4 | regtest_alter_user2
+ alt_nsp2 | alt_ts_conf2 | regtest_alter_user3
+(4 rows)
+
+--
+-- Text Search Template
+--
+CREATE TEXT SEARCH TEMPLATE alt_ts_temp1 (lexize=dsimple_lexize);
+CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize);
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp2; -- failed (name conflict)
+ERROR:  text search template "alt_ts_temp2" already exists
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp3; -- OK
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2;    -- OK
+CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize);
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2;    -- failed (name conflict)
+ERROR:  text search template alt_ts_temp2 already exists in schema "alt_nsp2"
+SELECT nspname, tmplname
+  FROM pg_ts_template t, pg_namespace n
+  WHERE t.tmplnamespace = n.oid AND nspname like 'alt_nsp%'
+  ORDER BY nspname, tmplname;
+ nspname  |   tmplname   
+----------+--------------
+ alt_nsp1 | alt_ts_temp2
+ alt_nsp1 | alt_ts_temp3
+ alt_nsp2 | alt_ts_temp2
+(3 rows)
+
+--
+-- Text Search Parser
+--
+CREATE TEXT SEARCH PARSER alt_ts_prs1
+    (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
+CREATE TEXT SEARCH PARSER alt_ts_prs2
+    (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
+ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs2; -- failed (name conflict)
+ERROR:  text search parser "alt_ts_prs2" already exists
+ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs3; -- OK
+ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2;   -- OK
+CREATE TEXT SEARCH PARSER alt_ts_prs2
+    (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
+ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2;   -- failed (name conflict)
+ERROR:  text search parser alt_ts_prs2 already exists in schema "alt_nsp2"
+SELECT nspname, prsname
+  FROM pg_ts_parser t, pg_namespace n
+  WHERE t.prsnamespace = n.oid AND nspname like 'alt_nsp%'
+  ORDER BY nspname, prsname;
+ nspname  |   prsname   
+----------+-------------
+ alt_nsp1 | alt_ts_prs2
+ alt_nsp1 | alt_ts_prs3
+ alt_nsp2 | alt_ts_prs2
+(3 rows)
+
+---
+--- Cleanup resources
+---
+DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
+NOTICE:  drop cascades to server alt_fserv2
+DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;
+NOTICE:  drop cascades to server alt_fserv3
+DROP LANGUAGE alt_lang2 CASCADE;
+DROP LANGUAGE alt_lang3 CASCADE;
+DROP LANGUAGE alt_lang4 CASCADE;
+ERROR:  language "alt_lang4" does not exist
+DROP SCHEMA alt_nsp1 CASCADE;
+NOTICE:  drop cascades to 29 other objects
+DETAIL:  drop cascades to function alt_func3(integer)
+drop cascades to function alt_agg3(integer)
+drop cascades to function alt_func4(integer)
+drop cascades to function alt_func2(integer)
+drop cascades to function alt_agg4(integer)
+drop cascades to function alt_agg2(integer)
+drop cascades to collation alt_coll3
+drop cascades to collation alt_coll4
+drop cascades to collation alt_coll2
+drop cascades to conversion alt_conv3
+drop cascades to conversion alt_conv4
+drop cascades to conversion alt_conv2
+drop cascades to operator @+@(integer,integer)
+drop cascades to operator @-@(integer,integer)
+drop cascades to operator family alt_opf3 for access method hash
+drop cascades to operator family alt_opc1 for access method hash
+drop cascades to operator family alt_opc2 for access method hash
+drop cascades to operator family alt_opf4 for access method hash
+drop cascades to operator family alt_opf2 for access method hash
+drop cascades to text search dictionary alt_ts_dict3
+drop cascades to text search dictionary alt_ts_dict4
+drop cascades to text search dictionary alt_ts_dict2
+drop cascades to text search configuration alt_ts_conf3
+drop cascades to text search configuration alt_ts_conf4
+drop cascades to text search configuration alt_ts_conf2
+drop cascades to text search template alt_ts_temp3
+drop cascades to text search template alt_ts_temp2
+drop cascades to text search parser alt_ts_prs3
+drop cascades to text search parser alt_ts_prs2
+DROP SCHEMA alt_nsp2 CASCADE;
+NOTICE:  drop cascades to 10 other objects
+DETAIL:  drop cascades to function alt_nsp2.alt_func2(integer)
+drop cascades to function alt_nsp2.alt_agg2(integer)
+drop cascades to collation alt_coll2
+drop cascades to conversion alt_conv2
+drop cascades to operator alt_nsp2.@-@(integer,integer)
+drop cascades to operator family alt_nsp2.alt_opf2 for access method hash
+drop cascades to text search dictionary alt_ts_dict2
+drop cascades to text search configuration alt_ts_conf2
+drop cascades to text search template alt_ts_temp2
+drop cascades to text search parser alt_ts_prs2
+DROP USER regtest_alter_user1;
+DROP USER regtest_alter_user2;
+DROP USER regtest_alter_user3;
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index ac29194..0e8a077 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -101,7 +101,7 @@ test: select_views portals_p2 foreign_key cluster dependency guc bitmapops combo
 # NB: temp.sql does a reconnect which transiently uses 2 connections,
 # so keep this parallel group to at most 19 tests
 # ----------
-test: plancache limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion truncate alter_table sequence polymorphism rowtypes returning largeobject with xml
+test: plancache limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion truncate alter_table alter_generic sequence polymorphism rowtypes returning largeobject with xml
 
 # run stats by itself because its delay may be insufficient under heavy load
 test: stats
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 8576a7f..f2813fb 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -125,6 +125,7 @@ test: without_oid
 test: conversion
 test: truncate
 test: alter_table
+test: alter_generic
 test: sequence
 test: polymorphism
 test: rowtypes
diff --git a/src/test/regress/sql/alter_generic.sql b/src/test/regress/sql/alter_generic.sql
new file mode 100644
index 0000000..8a19949
--- /dev/null
+++ b/src/test/regress/sql/alter_generic.sql
@@ -0,0 +1,413 @@
+--
+-- Test for ALTER RENAME TO/OWNER TO/SET SCHEMA
+--
+
+-- Clean up in case a prior regression run failed
+SET client_min_messages TO 'warning';
+
+DROP ROLE IF EXISTS regtest_alter_user1;
+DROP ROLE IF EXISTS regtest_alter_user2;
+DROP ROLE IF EXISTS regtest_alter_user3;
+
+RESET client_min_messages;
+
+CREATE USER regtest_alter_user3;
+CREATE USER regtest_alter_user2;
+CREATE USER regtest_alter_user1 IN ROLE regtest_alter_user3;
+
+CREATE SCHEMA alt_nsp1;
+CREATE SCHEMA alt_nsp2;
+
+GRANT ALL ON SCHEMA alt_nsp1, alt_nsp2 TO public;
+
+SET search_path = alt_nsp1, public;
+
+--
+-- Function and Aggregate
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 + 1';
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 - 1';
+CREATE AGGREGATE alt_agg1 (
+  sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
+);
+CREATE AGGREGATE alt_agg2 (
+  sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = 0
+);
+ALTER AGGREGATE alt_func1(int) RENAME TO alt_func3;  -- failed (not aggregate)
+ALTER AGGREGATE alt_func1(int) OWNER TO regtest_alter_user3;  -- failed (not aggregate)
+ALTER AGGREGATE alt_func1(int) SET SCHEMA alt_nsp2;  -- failed (not aggregate)
+
+ALTER FUNCTION alt_func1(int) RENAME TO alt_func2;  -- failed (name conflict)
+ALTER FUNCTION alt_func1(int) RENAME TO alt_func3;  -- OK
+ALTER FUNCTION alt_func2(int) OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER FUNCTION alt_func2(int) OWNER TO regtest_alter_user3;  -- OK
+ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2;  -- OK
+
+ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg2;   -- failed (name conflict)
+ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg3;   -- OK
+ALTER AGGREGATE alt_agg2(int) OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER AGGREGATE alt_agg2(int) OWNER TO regtest_alter_user3;  -- OK
+ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2;  -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 + 2';
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+  AS 'SELECT $1 - 2';
+CREATE AGGREGATE alt_agg1 (
+  sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
+);
+CREATE AGGREGATE alt_agg2 (
+  sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = -100
+);
+
+ALTER FUNCTION alt_func3(int) RENAME TO alt_func4;	-- failed (not owner)
+ALTER FUNCTION alt_func1(int) RENAME TO alt_func4;	-- OK
+ALTER FUNCTION alt_func3(int) OWNER TO regtest_alter_user2;	-- failed (not owner)
+ALTER FUNCTION alt_func2(int) OWNER TO regtest_alter_user3;	-- failed (no role membership)
+ALTER FUNCTION alt_func3(int) SET SCHEMA alt_nsp2;      -- failed (not owner)
+ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2;	-- failed (name conflicts)
+
+ALTER AGGREGATE alt_agg3(int) RENAME TO alt_agg4;   -- failed (not owner)
+ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg4;   -- OK
+ALTER AGGREGATE alt_agg3(int) OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER AGGREGATE alt_agg2(int) OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER AGGREGATE alt_agg3(int) SET SCHEMA alt_nsp2;  -- failed (not owner)
+ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+RESET SESSION AUTHORIZATION;
+
+SELECT n.nspname, proname, prorettype::regtype, proisagg, a.rolname
+  FROM pg_proc p, pg_namespace n, pg_authid a
+  WHERE p.pronamespace = n.oid AND p.proowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, proname;
+
+--
+-- Collation
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE COLLATION alt_coll1 (locale = 'C');
+CREATE COLLATION alt_coll2 (locale = 'C');
+
+ALTER COLLATION alt_coll1 RENAME TO alt_coll2;  -- failed (name conflict)
+ALTER COLLATION alt_coll1 RENAME TO alt_coll3;  -- OK
+ALTER COLLATION alt_coll2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER COLLATION alt_coll2 OWNER TO regtest_alter_user3;  -- OK
+ALTER COLLATION alt_coll2 SET SCHEMA alt_nsp2;  -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE COLLATION alt_coll1 (locale = 'C');
+CREATE COLLATION alt_coll2 (locale = 'C');
+
+ALTER COLLATION alt_coll3 RENAME TO alt_coll4;  -- failed (not owner)
+ALTER COLLATION alt_coll1 RENAME TO alt_coll4;  -- OK
+ALTER COLLATION alt_coll3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER COLLATION alt_coll2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER COLLATION alt_coll3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ALTER COLLATION alt_coll2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+RESET SESSION AUTHORIZATION;
+
+SELECT n.nspname, c.collname, a.rolname
+  FROM pg_collation c, pg_namespace n, pg_authid a
+  WHERE c.collnamespace = n.oid AND c.collowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY n.nspname, c.collname;
+
+--
+-- Conversion
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+
+ALTER CONVERSION alt_conv1 RENAME TO alt_conv2;  -- failed (name conflict)
+ALTER CONVERSION alt_conv1 RENAME TO alt_conv3;  -- OK
+ALTER CONVERSION alt_conv2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER CONVERSION alt_conv2 OWNER TO regtest_alter_user3;  -- OK
+ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2;  -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
+
+ALTER CONVERSION alt_conv3 RENAME TO alt_conv4;  -- failed (not owner)
+ALTER CONVERSION alt_conv1 RENAME TO alt_conv4;  -- OK
+ALTER CONVERSION alt_conv3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER CONVERSION alt_conv2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER CONVERSION alt_conv3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+RESET SESSION AUTHORIZATION;
+
+SELECT n.nspname, c.conname, a.rolname
+  FROM pg_conversion c, pg_namespace n, pg_authid a
+  WHERE c.connamespace = n.oid AND c.conowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, conname;
+
+--
+-- Foreign Data Wrapper and Foreign Server
+--
+CREATE FOREIGN DATA WRAPPER alt_fdw1;
+CREATE FOREIGN DATA WRAPPER alt_fdw2;
+
+CREATE SERVER alt_fserv1 FOREIGN DATA WRAPPER alt_fdw1;
+CREATE SERVER alt_fserv2 FOREIGN DATA WRAPPER alt_fdw2;
+
+ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw2;  -- failed (name conflict)
+ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw3;  -- OK
+
+ALTER SERVER alt_fserv1 RENAME TO alt_fserv2;   -- failed (name conflict)
+ALTER SERVER alt_fserv1 RENAME TO alt_fserv3;   -- OK
+
+SELECT fdwname FROM pg_foreign_data_wrapper WHERE fdwname like 'alt_fdw%';
+SELECT srvname FROM pg_foreign_server WHERE srvname like 'alt_fserv%';
+
+--
+-- Procedural Language
+--
+CREATE LANGUAGE alt_lang1 HANDLER plpgsql_call_handler;
+CREATE LANGUAGE alt_lang2 HANDLER plpgsql_call_handler;
+
+ALTER LANGUAGE alt_lang1 OWNER TO regtest_alter_user1;  -- OK
+ALTER LANGUAGE alt_lang2 OWNER TO regtest_alter_user2;  -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user1;
+ALTER LANGUAGE alt_lang1 RENAME TO alt_lang2;   -- failed (name conflict)
+ALTER LANGUAGE alt_lang2 RENAME TO alt_lang3;   -- failed (not owner)
+ALTER LANGUAGE alt_lang1 RENAME TO alt_lang3;   -- OK
+
+ALTER LANGUAGE alt_lang2 OWNER TO regtest_alter_user3;  -- failed (not owner)
+ALTER LANGUAGE alt_lang3 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER LANGUAGE alt_lang3 OWNER TO regtest_alter_user3;  -- OK
+
+RESET SESSION AUTHORIZATION;
+SELECT lanname, a.rolname
+  FROM pg_language l, pg_authid a
+  WHERE l.lanowner = a.oid AND l.lanname like 'alt_lang%'
+  ORDER BY lanname;
+
+--
+-- Operator
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+
+CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi );
+CREATE OPERATOR @+@ ( leftarg = int4, rightarg = int4, procedure = int4pl );
+
+ALTER OPERATOR @+@(int4, int4) OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER OPERATOR @+@(int4, int4) OWNER TO regtest_alter_user3;  -- OK
+ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2;           -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+
+CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi );
+
+ALTER OPERATOR @+@(int4, int4) OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER OPERATOR @-@(int4, int4) OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER OPERATOR @+@(int4, int4) SET SCHEMA alt_nsp2;   -- failed (not owner)
+-- ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2;   -- failed (name conflict)
+-- XXX it raises raw oid of namespace, it makes unneeded regression test fail...
+
+RESET SESSION AUTHORIZATION;
+
+SELECT n.nspname, oprname, a.rolname, oprleft::regtype, oprright::regtype, oprcode::regproc
+  FROM pg_operator o, pg_namespace n, pg_authid a
+  WHERE o.oprnamespace = n.oid AND o.oprowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, oprname;
+
+--
+-- OpFamily and OpClass
+--
+CREATE OPERATOR FAMILY alt_opf1 USING hash;
+CREATE OPERATOR FAMILY alt_opf2 USING hash;
+ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regtest_alter_user1;
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user1;
+
+CREATE OPERATOR CLASS alt_opc1 FOR TYPE uuid USING hash AS STORAGE uuid;
+CREATE OPERATOR CLASS alt_opc2 FOR TYPE uuid USING hash AS STORAGE uuid;
+ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regtest_alter_user1;
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user1;
+
+SET SESSION AUTHORIZATION regtest_alter_user1;
+
+ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf2;  -- failed (name conflict)
+ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf3;  -- OK
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user3;  -- OK
+ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2;  -- OK
+
+ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc2;  -- failed (name conflict)
+ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc3;  -- OK
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user3;  -- OK
+ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2;  -- OK
+
+RESET SESSION AUTHORIZATION;
+
+CREATE OPERATOR FAMILY alt_opf1 USING hash;
+CREATE OPERATOR FAMILY alt_opf2 USING hash;
+ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regtest_alter_user2;
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user2;
+
+CREATE OPERATOR CLASS alt_opc1 FOR TYPE macaddr USING hash AS STORAGE macaddr;
+CREATE OPERATOR CLASS alt_opc2 FOR TYPE macaddr USING hash AS STORAGE macaddr;
+ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regtest_alter_user2;
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user2;
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+
+ALTER OPERATOR FAMILY alt_opf3 USING hash RENAME TO alt_opf4;	-- failed (not owner)
+ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf4;  -- OK
+ALTER OPERATOR FAMILY alt_opf3 USING hash OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER OPERATOR FAMILY alt_opf3 USING hash SET SCHEMA alt_nsp2;  -- failed (not owner)
+-- ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+ALTER OPERATOR CLASS alt_opc3 USING hash RENAME TO alt_opc4;	-- failed (not owner)
+ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc4;  -- OK
+ALTER OPERATOR CLASS alt_opc3 USING hash OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER OPERATOR CLASS alt_opc3 USING hash SET SCHEMA alt_nsp2;  -- failed (not owner)
+-- ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+RESET SESSION AUTHORIZATION;
+
+SELECT nspname, opfname, amname, rolname
+  FROM pg_opfamily o, pg_am m, pg_namespace n, pg_authid a
+  WHERE o.opfmethod = m.oid AND o.opfnamespace = n.oid AND o.opfowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, opfname;
+
+SELECT nspname, opcname, amname, rolname
+  FROM pg_opclass o, pg_am m, pg_namespace n, pg_authid a
+  WHERE o.opcmethod = m.oid AND o.opcnamespace = n.oid AND o.opcowner = a.oid
+    AND n.nspname IN ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, opcname;
+
+--
+-- Text Search Dictionary
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple);
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple);
+
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict2;  -- failed (name conflict)
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict3;  -- OK
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regtest_alter_user3;  -- OK
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2;  -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple);
+CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple);
+
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 RENAME TO alt_ts_dict4;  -- failed (not owner)
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict4;  -- OK
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+RESET SESSION AUTHORIZATION;
+
+SELECT nspname, dictname, rolname
+  FROM pg_ts_dict t, pg_namespace n, pg_authid a
+  WHERE t.dictnamespace = n.oid AND t.dictowner = a.oid
+    AND n.nspname in ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, dictname;
+
+--
+-- Text Search Configuration
+--
+SET SESSION AUTHORIZATION regtest_alter_user1;
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english);
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english);
+
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf2;  -- failed (name conflict)
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf3;  -- OK
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regtest_alter_user2;  -- failed (no role membership)
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regtest_alter_user3;  -- OK
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2;  -- OK
+
+SET SESSION AUTHORIZATION regtest_alter_user2;
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english);
+CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english);
+
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 RENAME TO alt_ts_conf4;  -- failed (not owner)
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf4;  -- OK
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 OWNER TO regtest_alter_user2;  -- failed (not owner)
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regtest_alter_user3;  -- failed (no role membership)
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 SET SCHEMA alt_nsp2;  -- failed (not owner)
+ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2;  -- failed (name conflict)
+
+RESET SESSION AUTHORIZATION;
+
+SELECT nspname, cfgname, rolname
+  FROM pg_ts_config t, pg_namespace n, pg_authid a
+  WHERE t.cfgnamespace = n.oid AND t.cfgowner = a.oid
+    AND n.nspname in ('alt_nsp1', 'alt_nsp2')
+  ORDER BY nspname, cfgname;
+
+--
+-- Text Search Template
+--
+CREATE TEXT SEARCH TEMPLATE alt_ts_temp1 (lexize=dsimple_lexize);
+CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize);
+
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp2; -- failed (name conflict)
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp3; -- OK
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2;    -- OK
+
+CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize);
+ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2;    -- failed (name conflict)
+
+SELECT nspname, tmplname
+  FROM pg_ts_template t, pg_namespace n
+  WHERE t.tmplnamespace = n.oid AND nspname like 'alt_nsp%'
+  ORDER BY nspname, tmplname;
+
+--
+-- Text Search Parser
+--
+
+CREATE TEXT SEARCH PARSER alt_ts_prs1
+    (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
+CREATE TEXT SEARCH PARSER alt_ts_prs2
+    (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
+
+ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs2; -- failed (name conflict)
+ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs3; -- OK
+ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2;   -- OK
+
+CREATE TEXT SEARCH PARSER alt_ts_prs2
+    (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
+ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2;   -- failed (name conflict)
+
+SELECT nspname, prsname
+  FROM pg_ts_parser t, pg_namespace n
+  WHERE t.prsnamespace = n.oid AND nspname like 'alt_nsp%'
+  ORDER BY nspname, prsname;
+
+---
+--- Cleanup resources
+---
+DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
+DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;
+
+DROP LANGUAGE alt_lang2 CASCADE;
+DROP LANGUAGE alt_lang3 CASCADE;
+DROP LANGUAGE alt_lang4 CASCADE;
+
+DROP SCHEMA alt_nsp1 CASCADE;
+DROP SCHEMA alt_nsp2 CASCADE;
+
+DROP USER regtest_alter_user1;
+DROP USER regtest_alter_user2;
+DROP USER regtest_alter_user3;