You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ch...@apache.org on 2025/07/18 01:24:33 UTC

(cloudberry) branch cbdb-postgres-merge updated: Fix conflicts for c file in catalog

This is an automated email from the ASF dual-hosted git repository.

chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/cbdb-postgres-merge by this push:
     new 61cd3617f01 Fix conflicts for c file in catalog
61cd3617f01 is described below

commit 61cd3617f01814a32489e83043e62c028112d766
Author: Jinbao Chen <ch...@gmail.com>
AuthorDate: Fri Jul 18 09:24:21 2025 +0800

    Fix conflicts for c file in catalog
---
 src/backend/catalog/aclchk.c         | 1408 ++++------------------------------
 src/backend/catalog/catalog.c        |   41 +-
 src/backend/catalog/dependency.c     |   36 +-
 src/backend/catalog/index.c          |   44 --
 src/backend/catalog/namespace.c      |    3 -
 src/backend/catalog/objectaddress.c  |   84 +-
 src/backend/catalog/pg_depend.c      |    4 -
 src/backend/catalog/pg_proc.c        |    9 -
 src/backend/catalog/pg_publication.c |   87 +--
 src/backend/catalog/pg_type.c        |   12 -
 src/backend/catalog/toasting.c       |    4 -
 11 files changed, 148 insertions(+), 1584 deletions(-)

diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index a105ce50664..f4b495503aa 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -125,19 +125,6 @@ typedef struct
 bool		binary_upgrade_record_init_privs = false;
 
 static void ExecGrantStmt_oids(InternalGrant *istmt);
-<<<<<<< HEAD
-static void ExecGrant_Relation(InternalGrant *grantStmt);
-static void ExecGrant_Database(InternalGrant *grantStmt);
-static void ExecGrant_Fdw(InternalGrant *grantStmt);
-static void ExecGrant_ForeignServer(InternalGrant *grantStmt);
-static void ExecGrant_Function(InternalGrant *grantStmt);
-static void ExecGrant_Language(InternalGrant *grantStmt);
-static void ExecGrant_Largeobject(InternalGrant *grantStmt);
-static void ExecGrant_Namespace(InternalGrant *grantStmt);
-static void ExecGrant_Tablespace(InternalGrant *grantStmt);
-static void ExecGrant_ExtProtocol(InternalGrant *grantstmt);
-static void ExecGrant_Type(InternalGrant *grantStmt);
-=======
 static void ExecGrant_Relation(InternalGrant *istmt);
 static void ExecGrant_common(InternalGrant *istmt, Oid classid, AclMode default_privs,
 							 void (*object_check) (InternalGrant *istmt, HeapTuple tuple));
@@ -145,7 +132,7 @@ static void ExecGrant_Language_check(InternalGrant *istmt, HeapTuple tuple);
 static void ExecGrant_Largeobject(InternalGrant *istmt);
 static void ExecGrant_Type_check(InternalGrant *istmt, HeapTuple tuple);
 static void ExecGrant_Parameter(InternalGrant *istmt);
->>>>>>> REL_16_9
+static void ExecGrant_ExtProtocol(InternalGrant *grantstmt);
 
 static void SetDefaultACLsInSchemas(InternalDefaultACL *iacls, List *nspnames);
 static void SetDefaultACL(InternalDefaultACL *iacls);
@@ -315,13 +302,10 @@ restrict_and_check_grant(bool is_grant, AclMode avail_goptions, bool all_privs,
 		case OBJECT_TYPE:
 			whole_mask = ACL_ALL_RIGHTS_TYPE;
 			break;
-<<<<<<< HEAD
 		case OBJECT_EXTPROTOCOL:
 			whole_mask = ACL_ALL_RIGHTS_EXTPROTOCOL;
-=======
 		case OBJECT_PARAMETER_ACL:
 			whole_mask = ACL_ALL_RIGHTS_PARAMETER_ACL;
->>>>>>> REL_16_9
 			break;
 		default:
 			elog(ERROR, "unrecognized object type: %d", objtype);
@@ -572,7 +556,6 @@ ExecuteGrantStmt(GrantStmt *stmt)
 			all_privileges = ACL_ALL_RIGHTS_FOREIGN_SERVER;
 			errormsg = gettext_noop("invalid privilege type %s for foreign server");
 			break;
-<<<<<<< HEAD
 		case OBJECT_STORAGE_SERVER:
 			all_privileges = ACL_ALL_RIGHTS_STORAGE_SERVER;
 			errormsg = gettext_noop("invalid privilege type %s from storage server");
@@ -580,11 +563,9 @@ ExecuteGrantStmt(GrantStmt *stmt)
 		case OBJECT_EXTPROTOCOL:
 			all_privileges = ACL_ALL_RIGHTS_EXTPROTOCOL;
 			errormsg = gettext_noop("invalid privilege type %s for external protocol");
-=======
 		case OBJECT_PARAMETER_ACL:
 			all_privileges = ACL_ALL_RIGHTS_PARAMETER_ACL;
 			errormsg = gettext_noop("invalid privilege type %s for parameter");
->>>>>>> REL_16_9
 			break;
 		default:
 			elog(ERROR, "unrecognized GrantStmt.objtype: %d",
@@ -930,7 +911,6 @@ objectNamesToOids(ObjectType objtype, List *objnames, bool is_grant)
 				objects = lappend_oid(objects, srvid);
 			}
 			break;
-<<<<<<< HEAD
 		case OBJECT_EXTPROTOCOL:
 			foreach(cell, objnames)
 			{
@@ -938,7 +918,6 @@ objectNamesToOids(ObjectType objtype, List *objnames, bool is_grant)
 				Oid			ptcid = get_extprotocol_oid(ptcname, false);
 
 				objects = lappend_oid(objects, ptcid);
-=======
 		case OBJECT_PARAMETER_ACL:
 			foreach(cell, objnames)
 			{
@@ -968,7 +947,6 @@ objectNamesToOids(ObjectType objtype, List *objnames, bool is_grant)
 				}
 				if (OidIsValid(parameterId))
 					objects = lappend_oid(objects, parameterId);
->>>>>>> REL_16_9
 			}
 			break;
 		default:
@@ -1711,13 +1689,10 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
 			case ForeignDataWrapperRelationId:
 				istmt.objtype = OBJECT_FDW;
 				break;
-<<<<<<< HEAD
 			case ExtprotocolRelationId:
 				istmt.objtype = OBJECT_EXTPROTOCOL;
-=======
 			case ParameterAclRelationId:
 				istmt.objtype = OBJECT_PARAMETER_ACL;
->>>>>>> REL_16_9
 				break;
 			default:
 				elog(ERROR, "unexpected object class %u", classid);
@@ -2690,271 +2665,6 @@ ExecGrant_Parameter(InternalGrant *istmt)
 								   Anum_pg_parameter_acl_paracl,
 								   &isNull);
 
-<<<<<<< HEAD
-		/* Determine ID to do the grant as, and available grant options */
-		select_best_grantor(GetUserId(), istmt->privileges,
-							old_acl, ownerId,
-							&grantorId, &avail_goptions);
-
-		/*
-		 * Restrict the privileges to what we can actually grant, and emit the
-		 * standards-mandated warning and error messages.
-		 */
-		this_privileges =
-			restrict_and_check_grant(istmt->is_grant, avail_goptions,
-									 istmt->all_privs, istmt->privileges,
-									 nspid, grantorId, OBJECT_SCHEMA,
-									 NameStr(pg_namespace_tuple->nspname),
-									 0, NULL);
-
-		/*
-		 * Generate new ACL.
-		 */
-		new_acl = merge_acl_with_grant(old_acl, istmt->is_grant,
-									   istmt->grant_option, istmt->behavior,
-									   istmt->grantees, this_privileges,
-									   grantorId, ownerId);
-
-		/*
-		 * We need the members of both old and new ACLs so we can correct the
-		 * shared dependency information.
-		 */
-		nnewmembers = aclmembers(new_acl, &newmembers);
-
-		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
-
-		replaces[Anum_pg_namespace_nspacl - 1] = true;
-		values[Anum_pg_namespace_nspacl - 1] = PointerGetDatum(new_acl);
-
-		newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
-									 nulls, replaces);
-
-		CatalogTupleUpdate(relation, &newtuple->t_self, newtuple);
-
-		/* MPP-6929: metadata tracking */
-		if (Gp_role == GP_ROLE_DISPATCH)
-			MetaTrackUpdObject(NamespaceRelationId,
-							   nspid,
-							   GetUserId(), /* not grantorId, */
-							   "PRIVILEGE", 
-							   (istmt->is_grant) ? "GRANT" : "REVOKE"
-					);
-
-		/* Update initial privileges for extensions */
-		recordExtensionInitPriv(nspid, NamespaceRelationId, 0, new_acl);
-
-		/* Update the shared dependency ACL info */
-		updateAclDependencies(NamespaceRelationId, pg_namespace_tuple->oid, 0,
-							  ownerId,
-							  noldmembers, oldmembers,
-							  nnewmembers, newmembers);
-
-		ReleaseSysCache(tuple);
-
-		pfree(new_acl);
-
-		/* prevent error when processing duplicate objects */
-		CommandCounterIncrement();
-	}
-
-	table_close(relation, RowExclusiveLock);
-}
-
-static void
-ExecGrant_Tablespace(InternalGrant *istmt)
-{
-	Relation	relation;
-	ListCell   *cell;
-
-	if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
-		istmt->privileges = ACL_ALL_RIGHTS_TABLESPACE;
-
-	relation = table_open(TableSpaceRelationId, RowExclusiveLock);
-
-	foreach(cell, istmt->objects)
-	{
-		Oid			tblId = lfirst_oid(cell);
-		Form_pg_tablespace pg_tablespace_tuple;
-		Datum		aclDatum;
-		bool		isNull;
-		AclMode		avail_goptions;
-		AclMode		this_privileges;
-		Acl		   *old_acl;
-		Acl		   *new_acl;
-		Oid			grantorId;
-		Oid			ownerId;
-		HeapTuple	newtuple;
-		Datum		values[Natts_pg_tablespace];
-		bool		nulls[Natts_pg_tablespace];
-		bool		replaces[Natts_pg_tablespace];
-		int			noldmembers;
-		int			nnewmembers;
-		Oid		   *oldmembers;
-		Oid		   *newmembers;
-		HeapTuple	tuple;
-
-		/* Search syscache for pg_tablespace */
-		tuple = SearchSysCache1(TABLESPACEOID, ObjectIdGetDatum(tblId));
-		if (!HeapTupleIsValid(tuple))
-			elog(ERROR, "cache lookup failed for tablespace %u", tblId);
-
-		pg_tablespace_tuple = (Form_pg_tablespace) GETSTRUCT(tuple);
-
-		/*
-		 * Get owner ID and working copy of existing ACL. If there's no ACL,
-		 * substitute the proper default.
-		 */
-		ownerId = pg_tablespace_tuple->spcowner;
-		aclDatum = heap_getattr(tuple, Anum_pg_tablespace_spcacl,
-								RelationGetDescr(relation), &isNull);
-		if (isNull)
-		{
-			old_acl = acldefault(OBJECT_TABLESPACE, ownerId);
-			/* There are no old member roles according to the catalogs */
-			noldmembers = 0;
-			oldmembers = NULL;
-		}
-		else
-		{
-			old_acl = DatumGetAclPCopy(aclDatum);
-			/* Get the roles mentioned in the existing ACL */
-			noldmembers = aclmembers(old_acl, &oldmembers);
-		}
-
-		/* Determine ID to do the grant as, and available grant options */
-		select_best_grantor(GetUserId(), istmt->privileges,
-							old_acl, ownerId,
-							&grantorId, &avail_goptions);
-
-		/*
-		 * Restrict the privileges to what we can actually grant, and emit the
-		 * standards-mandated warning and error messages.
-		 */
-		this_privileges =
-			restrict_and_check_grant(istmt->is_grant, avail_goptions,
-									 istmt->all_privs, istmt->privileges,
-									 tblId, grantorId, OBJECT_TABLESPACE,
-									 NameStr(pg_tablespace_tuple->spcname),
-									 0, NULL);
-
-		/*
-		 * Generate new ACL.
-		 */
-		new_acl = merge_acl_with_grant(old_acl, istmt->is_grant,
-									   istmt->grant_option, istmt->behavior,
-									   istmt->grantees, this_privileges,
-									   grantorId, ownerId);
-
-		/*
-		 * We need the members of both old and new ACLs so we can correct the
-		 * shared dependency information.
-		 */
-		nnewmembers = aclmembers(new_acl, &newmembers);
-
-		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
-
-		replaces[Anum_pg_tablespace_spcacl - 1] = true;
-		values[Anum_pg_tablespace_spcacl - 1] = PointerGetDatum(new_acl);
-
-		newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
-									 nulls, replaces);
-
-		CatalogTupleUpdate(relation, &newtuple->t_self, newtuple);
-
-		/* MPP-6929: metadata tracking */
-		if (Gp_role == GP_ROLE_DISPATCH)
-			MetaTrackUpdObject(TableSpaceRelationId,
-							   tblId,
-							   GetUserId(), /* not grantorId, */
-							   "PRIVILEGE", 
-							   (istmt->is_grant) ? "GRANT" : "REVOKE"
-					);
-
-		/* Update the shared dependency ACL info */
-		updateAclDependencies(TableSpaceRelationId, tblId, 0,
-							  ownerId,
-							  noldmembers, oldmembers,
-							  nnewmembers, newmembers);
-
-		ReleaseSysCache(tuple);
-		pfree(new_acl);
-
-		/* prevent error when processing duplicate objects */
-		CommandCounterIncrement();
-	}
-
-	table_close(relation, RowExclusiveLock);
-}
-
-static void
-ExecGrant_Type(InternalGrant *istmt)
-{
-	Relation	relation;
-	ListCell   *cell;
-
-	if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
-		istmt->privileges = ACL_ALL_RIGHTS_TYPE;
-
-	relation = table_open(TypeRelationId, RowExclusiveLock);
-
-	foreach(cell, istmt->objects)
-	{
-		Oid			typId = lfirst_oid(cell);
-		Form_pg_type pg_type_tuple;
-		Datum		aclDatum;
-		bool		isNull;
-		AclMode		avail_goptions;
-		AclMode		this_privileges;
-		Acl		   *old_acl;
-		Acl		   *new_acl;
-		Oid			grantorId;
-		Oid			ownerId;
-		HeapTuple	newtuple;
-		Datum		values[Natts_pg_type];
-		bool		nulls[Natts_pg_type];
-		bool		replaces[Natts_pg_type];
-		int			noldmembers;
-		int			nnewmembers;
-		Oid		   *oldmembers;
-		Oid		   *newmembers;
-		HeapTuple	tuple;
-
-		/* Search syscache for pg_type */
-		tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typId));
-		if (!HeapTupleIsValid(tuple))
-			elog(ERROR, "cache lookup failed for type %u", typId);
-
-		pg_type_tuple = (Form_pg_type) GETSTRUCT(tuple);
-
-		if (IsTrueArrayType(pg_type_tuple))
-			ereport(ERROR,
-					(errcode(ERRCODE_INVALID_GRANT_OPERATION),
-					 errmsg("cannot set privileges of array types"),
-					 errhint("Set the privileges of the element type instead.")));
-
-		/* Used GRANT DOMAIN on a non-domain? */
-		if (istmt->objtype == OBJECT_DOMAIN &&
-			pg_type_tuple->typtype != TYPTYPE_DOMAIN)
-			ereport(ERROR,
-					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
-					 errmsg("\"%s\" is not a domain",
-							NameStr(pg_type_tuple->typname))));
-
-		/*
-		 * Get owner ID and working copy of existing ACL. If there's no ACL,
-		 * substitute the proper default.
-		 */
-		ownerId = pg_type_tuple->typowner;
-		aclDatum = heap_getattr(tuple, Anum_pg_type_typacl,
-								RelationGetDescr(relation), &isNull);
-=======
->>>>>>> REL_16_9
 		if (isNull)
 		{
 			old_acl = acldefault(istmt->objtype, ownerId);
@@ -3448,13 +3158,9 @@ aclcheck_error(AclResult aclerr, ObjectType objtype,
 					case OBJECT_TSPARSER:
 					case OBJECT_TSTEMPLATE:
 					case OBJECT_USER_MAPPING:
-<<<<<<< HEAD
 					case OBJECT_PROFILE:
 					case OBJECT_STORAGE_USER_MAPPING:
-						elog(ERROR, "unsupported object type %d", objtype);
-=======
 						elog(ERROR, "unsupported object type: %d", objtype);
->>>>>>> REL_16_9
 				}
 
 				ereport(ERROR,
@@ -3603,14 +3309,10 @@ aclcheck_error(AclResult aclerr, ObjectType objtype,
 					case OBJECT_TSPARSER:
 					case OBJECT_TSTEMPLATE:
 					case OBJECT_USER_MAPPING:
-<<<<<<< HEAD
 					case OBJECT_PROFILE:
 					case OBJECT_STORAGE_SERVER:
 					case OBJECT_STORAGE_USER_MAPPING:
-						elog(ERROR, "unsupported object type %d", objtype);
-=======
 						elog(ERROR, "unsupported object type: %d", objtype);
->>>>>>> REL_16_9
 				}
 
 				ereport(ERROR,
@@ -3708,13 +3410,9 @@ pg_aclmask(ObjectType objtype, Oid object_oid, AttrNumber attnum, Oid roleid,
 			/* not reached, but keep compiler quiet */
 			return ACL_NO_RIGHTS;
 		case OBJECT_TYPE:
-<<<<<<< HEAD
-			return pg_type_aclmask(table_oid, roleid, mask, how);
+			return object_aclmask(TypeRelationId, object_oid, roleid, mask, how);
 		case OBJECT_EXTPROTOCOL:
 			return pg_extprotocol_aclmask(table_oid, roleid, mask, how);
-=======
-			return object_aclmask(TypeRelationId, object_oid, roleid, mask, how);
->>>>>>> REL_16_9
 		default:
 			elog(ERROR, "unrecognized object type: %d",
 				 (int) objtype);
@@ -4354,48 +4052,50 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
 }
 
 /*
- * Routine for examining a user's privileges for a type.
+ * Exported routine for examining a user's privileges for a storage
+ * server.
  */
-<<<<<<< HEAD
 AclMode
-pg_tablespace_aclmask(Oid spc_oid, Oid roleid,
-					  AclMode mask, AclMaskHow how)
+gp_storage_server_aclmask(Oid srv_oid, Oid roleid,
+						AclMode mask, AclMaskHow how)
 {
 	AclMode		result;
 	HeapTuple	tuple;
 	Datum		aclDatum;
 	bool		isNull;
-	Acl		   *acl;
-	Oid			ownerId;
+	Acl		*acl;
+	Oid		ownerId;
 
-	/* Superusers bypass all permission checking. */
+	Form_gp_storage_server srvForm;
+
+	/* Bypass permission checks for superusers */
 	if (superuser_arg(roleid))
 		return mask;
 
-	/*
-	 * Get the tablespace's ACL from pg_tablespace
-	 */
-	tuple = SearchSysCache1(TABLESPACEOID, ObjectIdGetDatum(spc_oid));
+	tuple = SearchSysCache1(STORAGESERVEROID, ObjectIdGetDatum(srv_oid));
 	if (!HeapTupleIsValid(tuple))
 		ereport(ERROR,
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("tablespace with OID %u does not exist", spc_oid)));
-
-	ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner;
+				 errmsg("storage server with OID %u does not exist",
+					    srv_oid)));
+	srvForm = (Form_gp_storage_server) GETSTRUCT(tuple);
 
-	aclDatum = SysCacheGetAttr(TABLESPACEOID, tuple,
-							   Anum_pg_tablespace_spcacl,
-							   &isNull);
+	/*
+	 * Normal case: get the storage server's ACL from gp_storage_server
+	 */
+	ownerId = srvForm->srvowner;
 
+	aclDatum = SysCacheGetAttr(STORAGESERVEROID, tuple,
+							   Anum_gp_storage_server_srvacl, &isNull);
 	if (isNull)
 	{
 		/* No ACL, so build default ACL */
-		acl = acldefault(OBJECT_TABLESPACE, ownerId);
+		acl = acldefault(OBJECT_STORAGE_SERVER, ownerId);
 		aclDatum = (Datum) 0;
 	}
 	else
 	{
-		/* detoast ACL if necessary */
+		/* detoast rel's ACL if necessary */
 		acl = DatumGetAclP(aclDatum);
 	}
 
@@ -4411,12 +4111,10 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid,
 }
 
 /*
- * Exported routine for examining a user's privileges for a foreign
- * data wrapper
+ * Exported routine for examining a user's privileges for a type.
  */
 AclMode
-pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
-								AclMode mask, AclMaskHow how)
+pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
 {
 	AclMode		result;
 	HeapTuple	tuple;
@@ -4425,96 +4123,51 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
 	Acl		   *acl;
 	Oid			ownerId;
 
-	Form_pg_foreign_data_wrapper fdwForm;
+	Form_pg_type typeForm;
 
 	/* Bypass permission checks for superusers */
 	if (superuser_arg(roleid))
 		return mask;
 
 	/*
-	 * Must get the FDW's tuple from pg_foreign_data_wrapper
+	 * Must get the type's tuple from pg_type
 	 */
-	tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdw_oid));
+	tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid));
 	if (!HeapTupleIsValid(tuple))
 		ereport(ERROR,
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("foreign-data wrapper with OID %u does not exist",
-						fdw_oid)));
-	fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
+				 errmsg("type with OID %u does not exist",
+						type_oid)));
+	typeForm = (Form_pg_type) GETSTRUCT(tuple);
 
 	/*
-	 * Normal case: get the FDW's ACL from pg_foreign_data_wrapper
+	 * "True" array types don't manage permissions of their own; consult the
+	 * element type instead.
 	 */
-	ownerId = fdwForm->fdwowner;
-
-	aclDatum = SysCacheGetAttr(FOREIGNDATAWRAPPEROID, tuple,
-							   Anum_pg_foreign_data_wrapper_fdwacl, &isNull);
-	if (isNull)
+	if (IsTrueArrayType(typeForm))
 	{
-		/* No ACL, so build default ACL */
-		acl = acldefault(OBJECT_FDW, ownerId);
-		aclDatum = (Datum) 0;
-	}
-	else
-	{
-		/* detoast rel's ACL if necessary */
-		acl = DatumGetAclP(aclDatum);
-	}
-
-	result = aclmask(acl, roleid, ownerId, mask, how);
-
-	/* if we have a detoasted copy, free it */
-	if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
-		pfree(acl);
-
-	ReleaseSysCache(tuple);
-
-	return result;
-}
-
-/*
- * Exported routine for examining a user's privileges for a foreign
- * server.
- */
-AclMode
-pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
-						  AclMode mask, AclMaskHow how)
-{
-	AclMode		result;
-	HeapTuple	tuple;
-	Datum		aclDatum;
-	bool		isNull;
-	Acl		   *acl;
-	Oid			ownerId;
-
-	Form_pg_foreign_server srvForm;
+		Oid			elttype_oid = typeForm->typelem;
 
-	/* Bypass permission checks for superusers */
-	if (superuser_arg(roleid))
-		return mask;
+		ReleaseSysCache(tuple);
 
-	/*
-	 * Must get the FDW's tuple from pg_foreign_data_wrapper
-	 */
-	tuple = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srv_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("foreign server with OID %u does not exist",
-						srv_oid)));
-	srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple);
+		tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(elttype_oid));
+		/* this case is not a user-facing error, so elog not ereport */
+		if (!HeapTupleIsValid(tuple))
+			elog(ERROR, "cache lookup failed for type %u", elttype_oid);
+		typeForm = (Form_pg_type) GETSTRUCT(tuple);
+	}
 
 	/*
-	 * Normal case: get the foreign server's ACL from pg_foreign_server
+	 * Now get the type's owner and ACL from the tuple
 	 */
-	ownerId = srvForm->srvowner;
+	ownerId = typeForm->typowner;
 
-	aclDatum = SysCacheGetAttr(FOREIGNSERVEROID, tuple,
-							   Anum_pg_foreign_server_srvacl, &isNull);
+	aclDatum = SysCacheGetAttr(TYPEOID, tuple,
+							   Anum_pg_type_typacl, &isNull);
 	if (isNull)
 	{
 		/* No ACL, so build default ACL */
-		acl = acldefault(OBJECT_FOREIGN_SERVER, ownerId);
+		acl = acldefault(OBJECT_TYPE, ownerId);
 		aclDatum = (Datum) 0;
 	}
 	else
@@ -4535,125 +4188,62 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
 }
 
 /*
- * Exported routine for examining a user's privileges for a storage
- * server.
+ * Exported routine for examining a user's privileges for an external
+ * protocol.
  */
 AclMode
-gp_storage_server_aclmask(Oid srv_oid, Oid roleid,
-						AclMode mask, AclMaskHow how)
+pg_extprotocol_aclmask(Oid ptcOid, Oid roleid,
+                       AclMode mask, AclMaskHow how)
 {
-	AclMode		result;
-	HeapTuple	tuple;
-	Datum		aclDatum;
-	bool		isNull;
-	Acl		*acl;
-	Oid		ownerId;
-
-	Form_gp_storage_server srvForm;
+	AclMode result;
+	HeapTuple tuple;
+	Datum aclDatum;
+	Datum ownerDatum;
+	bool isNull;
+	Acl *acl;
+	Oid ownerId;
+	Relation rel;
+	ScanKeyData scankey;
+	SysScanDesc sscan;
 
 	/* Bypass permission checks for superusers */
 	if (superuser_arg(roleid))
 		return mask;
 
-	tuple = SearchSysCache1(STORAGESERVEROID, ObjectIdGetDatum(srv_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("storage server with OID %u does not exist",
-					    srv_oid)));
-	srvForm = (Form_gp_storage_server) GETSTRUCT(tuple);
-
-	/*
-	 * Normal case: get the storage server's ACL from gp_storage_server
-	 */
-	ownerId = srvForm->srvowner;
-
-	aclDatum = SysCacheGetAttr(STORAGESERVEROID, tuple,
-							   Anum_gp_storage_server_srvacl, &isNull);
-	if (isNull)
-	{
-		/* No ACL, so build default ACL */
-		acl = acldefault(OBJECT_STORAGE_SERVER, ownerId);
-		aclDatum = (Datum) 0;
-	}
-	else
-	{
-		/* detoast rel's ACL if necessary */
-		acl = DatumGetAclP(aclDatum);
-	}
-
-	result = aclmask(acl, roleid, ownerId, mask, how);
-
-	/* if we have a detoasted copy, free it */
-	if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
-		pfree(acl);
-
-	ReleaseSysCache(tuple);
-
-	return result;
-}
+	rel = heap_open(ExtprotocolRelationId, AccessShareLock);
 
-/*
- * Exported routine for examining a user's privileges for a type.
- */
-AclMode
-=======
-static AclMode
->>>>>>> REL_16_9
-pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
-{
-	AclMode		result;
-	HeapTuple	tuple;
-	Datum		aclDatum;
-	bool		isNull;
-	Acl		   *acl;
-	Oid			ownerId;
+	ScanKeyInit(&scankey, Anum_pg_extprotocol_oid,
+				BTEqualStrategyNumber, F_OIDEQ,
+				ObjectIdGetDatum(ptcOid));
+	sscan = systable_beginscan(rel, ExtprotocolOidIndexId, true,
+							   NULL, 1, &scankey);
+	tuple = systable_getnext(sscan);
 
-	Form_pg_type typeForm;
+	/* We assume that there can be at most one matching tuple */
+	if (!HeapTupleIsValid(tuple))
+		elog(ERROR, "protocol %u could not be found", ptcOid);
 
-	/* Bypass permission checks for superusers */
-	if (superuser_arg(roleid))
-		return mask;
+	ownerDatum = heap_getattr(tuple,
+							  Anum_pg_extprotocol_ptcowner,
+							  RelationGetDescr(rel),
+							  &isNull);
 
-	/*
-	 * Must get the type's tuple from pg_type
-	 */
-	tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid));
-	if (!HeapTupleIsValid(tuple))
+	if (isNull)
 		ereport(ERROR,
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("type with OID %u does not exist",
-						type_oid)));
-	typeForm = (Form_pg_type) GETSTRUCT(tuple);
-
-	/*
-	 * "True" array types don't manage permissions of their own; consult the
-	 * element type instead.
-	 */
-	if (IsTrueArrayType(typeForm))
-	{
-		Oid			elttype_oid = typeForm->typelem;
-
-		ReleaseSysCache(tuple);
+						errmsg("got invalid extprotocol owner value: NULL")));
 
-		tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(elttype_oid));
-		/* this case is not a user-facing error, so elog not ereport */
-		if (!HeapTupleIsValid(tuple))
-			elog(ERROR, "cache lookup failed for type %u", elttype_oid);
-		typeForm = (Form_pg_type) GETSTRUCT(tuple);
-	}
+	ownerId = DatumGetObjectId(ownerDatum);
 
-	/*
-	 * Now get the type's owner and ACL from the tuple
-	 */
-	ownerId = typeForm->typowner;
+	aclDatum = heap_getattr(tuple,
+							Anum_pg_extprotocol_ptcacl,
+							RelationGetDescr(rel),
+							&isNull);
 
-	aclDatum = SysCacheGetAttr(TYPEOID, tuple,
-							   Anum_pg_type_typacl, &isNull);
 	if (isNull)
 	{
 		/* No ACL, so build default ACL */
-		acl = acldefault(OBJECT_TYPE, ownerId);
+		acl = acldefault(OBJECT_EXTPROTOCOL, ownerId);
 		aclDatum = (Datum) 0;
 	}
 	else
@@ -4668,89 +4258,14 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
 	if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
 		pfree(acl);
 
-	ReleaseSysCache(tuple);
+	/* Finish up scan and close pg_extprotocol catalog. */
+	systable_endscan(sscan);
+	heap_close(rel, AccessShareLock);
 
 	return result;
 }
 
 /*
-<<<<<<< HEAD
- * Exported routine for examining a user's privileges for an external
- * protocol.
- */
-AclMode
-pg_extprotocol_aclmask(Oid ptcOid, Oid roleid,
-                       AclMode mask, AclMaskHow how)
-{
-    AclMode		result;
-    HeapTuple	tuple;
-    Datum		aclDatum;
-    Datum		ownerDatum;
-    bool		isNull;
-    Acl		   *acl;
-    Oid			ownerId;
-    Relation	rel;
-    ScanKeyData scankey;
-    SysScanDesc sscan;
-
-    /* Bypass permission checks for superusers */
-    if (superuser_arg(roleid))
-        return mask;
-
-    rel = heap_open(ExtprotocolRelationId, AccessShareLock);
-
-    ScanKeyInit(&scankey, Anum_pg_extprotocol_oid,
-                BTEqualStrategyNumber, F_OIDEQ,
-                ObjectIdGetDatum(ptcOid));
-    sscan = systable_beginscan(rel, ExtprotocolOidIndexId, true,
-                               NULL, 1, &scankey);
-    tuple = systable_getnext(sscan);
-
-    /* We assume that there can be at most one matching tuple */
-    if (!HeapTupleIsValid(tuple))
-        elog(ERROR, "protocol %u could not be found", ptcOid);
-
-    ownerDatum = heap_getattr(tuple,
-                              Anum_pg_extprotocol_ptcowner,
-                              RelationGetDescr(rel),
-                              &isNull);
-
-    if(isNull)
-        ereport(ERROR,
-                (errcode(ERRCODE_UNDEFINED_OBJECT),
-                        errmsg("got invalid extprotocol owner value: NULL")));
-
-    ownerId = DatumGetObjectId(ownerDatum);
-
-    aclDatum = heap_getattr(tuple,
-                            Anum_pg_extprotocol_ptcacl,
-                            RelationGetDescr(rel),
-                            &isNull);
-
-    if (isNull)
-    {
-        /* No ACL, so build default ACL */
-        acl = acldefault(OBJECT_EXTPROTOCOL, ownerId);
-        aclDatum = (Datum) 0;
-    }
-    else
-    {
-        /* detoast rel's ACL if necessary */
-        acl = DatumGetAclP(aclDatum);
-    }
-
-    result = aclmask(acl, roleid, ownerId, mask, how);
-
-    /* if we have a detoasted copy, free it */
-    if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
-        pfree(acl);
-
-    /* Finish up scan and close pg_extprotocol catalog. */
-    systable_endscan(sscan);
-    heap_close(rel, AccessShareLock);
-
-    return result;
-=======
  * Exported generic routine for checking a user's access privileges to an object
  */
 AclResult
@@ -4760,7 +4275,6 @@ object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
 		return ACLCHECK_OK;
 	else
 		return ACLCHECK_NO_PRIV;
->>>>>>> REL_16_9
 }
 
 /*
@@ -4987,71 +4501,42 @@ object_ownercheck(Oid classid, Oid objectid, Oid roleid)
 		ReleaseSysCache(tuple);
 	}
 	else
-<<<<<<< HEAD
-		return ACLCHECK_NO_PRIV;
-}
+	{
+		/* for catalogs without an appropriate syscache */
+		Relation	rel;
+		ScanKeyData entry[1];
+		SysScanDesc scan;
+		HeapTuple	tuple;
+		bool		isnull;
 
-/*
- * Exported routine for checking a user's access privileges to a tablespace
- */
-AclResult
-pg_tablespace_aclcheck(Oid spc_oid, Oid roleid, AclMode mode)
-{
-	if (pg_tablespace_aclmask(spc_oid, roleid, mode, ACLMASK_ANY) != 0)
-		return ACLCHECK_OK;
-	else
-		return ACLCHECK_NO_PRIV;
-}
+		rel = table_open(classid, AccessShareLock);
 
-/*
- * Exported routine for checking a user's access privileges to a foreign
- * data wrapper
- */
-AclResult
-pg_foreign_data_wrapper_aclcheck(Oid fdw_oid, Oid roleid, AclMode mode)
-{
-	if (pg_foreign_data_wrapper_aclmask(fdw_oid, roleid, mode, ACLMASK_ANY) != 0)
-		return ACLCHECK_OK;
-	else
-		return ACLCHECK_NO_PRIV;
-}
+		ScanKeyInit(&entry[0],
+					get_object_attnum_oid(classid),
+					BTEqualStrategyNumber, F_OIDEQ,
+					ObjectIdGetDatum(objectid));
 
-/*
- * Exported routine for checking a user's access privileges to a foreign
- * server
- */
-AclResult
-pg_foreign_server_aclcheck(Oid srv_oid, Oid roleid, AclMode mode)
-{
-	if (pg_foreign_server_aclmask(srv_oid, roleid, mode, ACLMASK_ANY) != 0)
-		return ACLCHECK_OK;
-	else
-		return ACLCHECK_NO_PRIV;
-}
+		scan = systable_beginscan(rel,
+								  get_object_oid_index(classid), true,
+								  NULL, 1, entry);
 
-/*
- * Exported routine for checking a user's access privileges to a storage
- * server
- */
-AclResult
-gp_storage_server_aclcheck(Oid srv_oid, Oid roleid, AclMode mode)
-{
-	if (gp_storage_server_aclmask(srv_oid, roleid, mode, ACLMASK_ANY) != 0)
-		return ACLCHECK_OK;
-	else
-		return ACLCHECK_NO_PRIV;
-}
+		tuple = systable_getnext(scan);
+		if (!HeapTupleIsValid(tuple))
+			ereport(ERROR,
+					(errcode(ERRCODE_UNDEFINED_OBJECT),
+					 errmsg("%s with OID %u does not exist", get_object_class_descr(classid), objectid)));
 
-/*
- * Exported routine for checking a user's access privileges to a type
- */
-AclResult
-pg_type_aclcheck(Oid type_oid, Oid roleid, AclMode mode)
-{
-	if (pg_type_aclmask(type_oid, roleid, mode, ACLMASK_ANY) != 0)
-		return ACLCHECK_OK;
-	else
-		return ACLCHECK_NO_PRIV;
+		ownerId = DatumGetObjectId(heap_getattr(tuple,
+												get_object_attnum_owner(classid),
+												RelationGetDescr(rel),
+												&isnull));
+		Assert(!isnull);
+
+		systable_endscan(scan);
+		table_close(rel, AccessShareLock);
+	}
+
+	return has_privs_of_role(roleid, ownerId);
 }
 
 /*
@@ -5061,17 +4546,17 @@ pg_type_aclcheck(Oid type_oid, Oid roleid, AclMode mode)
 AclResult
 pg_extprotocol_aclcheck(Oid ptcid, Oid roleid, AclMode mode)
 {
-    if (pg_extprotocol_aclmask(ptcid, roleid, mode, ACLMASK_ANY) != 0)
-        return ACLCHECK_OK;
-    else
-        return ACLCHECK_NO_PRIV;
+	if (pg_extprotocol_aclmask(ptcid, roleid, mode, ACLMASK_ANY) != 0)
+		return ACLCHECK_OK;
+	else
+		return ACLCHECK_NO_PRIV;
 }
 
 /*
- * Ownership check for a relation (specified by OID).
+ * Ownership check for a tag (specified by OID).
  */
 bool
-pg_class_ownercheck(Oid class_oid, Oid roleid)
+pg_tag_ownercheck(Oid tag_oid, Oid roleid)
 {
 	HeapTuple	tuple;
 	Oid			ownerId;
@@ -5080,13 +4565,14 @@ pg_class_ownercheck(Oid class_oid, Oid roleid)
 	if (superuser_arg(roleid))
 		return true;
 
-	tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(class_oid));
+	tuple = SearchSysCache1(TAGOID, ObjectIdGetDatum(tag_oid));
 	if (!HeapTupleIsValid(tuple))
 		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_TABLE),
-				 errmsg("relation with OID %u does not exist", class_oid)));
+				(errcode(ERRCODE_UNDEFINED_OBJECT),
+						errmsg("tag with OID %u does not exist",
+							   tag_oid)));
 
-	ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
+	ownerId = ((Form_pg_tag) GETSTRUCT(tuple))->tagowner;
 
 	ReleaseSysCache(tuple);
 
@@ -5094,402 +4580,10 @@ pg_class_ownercheck(Oid class_oid, Oid roleid)
 }
 
 /*
- * Ownership check for a type (specified by OID).
+ * Ownership check for a storage server (specified by OID).
  */
 bool
-pg_type_ownercheck(Oid type_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("type with OID %u does not exist", type_oid)));
-
-	ownerId = ((Form_pg_type) GETSTRUCT(tuple))->typowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for an operator (specified by OID).
- */
-bool
-pg_oper_ownercheck(Oid oper_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(oper_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_FUNCTION),
-				 errmsg("operator with OID %u does not exist", oper_oid)));
-
-	ownerId = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a function (specified by OID).
- */
-bool
-pg_proc_ownercheck(Oid proc_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(proc_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_FUNCTION),
-				 errmsg("function with OID %u does not exist", proc_oid)));
-
-	ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a procedural language (specified by OID)
- */
-bool
-pg_language_ownercheck(Oid lan_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(lan_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_FUNCTION),
-				 errmsg("language with OID %u does not exist", lan_oid)));
-
-	ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a largeobject (specified by OID)
- *
- * This is only used for operations like ALTER LARGE OBJECT that are always
- * relative to an up-to-date snapshot.
- */
-bool
-pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
-{
-	Relation	pg_lo_meta;
-	ScanKeyData entry[1];
-	SysScanDesc scan;
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	/* There's no syscache for pg_largeobject_metadata */
-	pg_lo_meta = table_open(LargeObjectMetadataRelationId,
-							AccessShareLock);
-
-	ScanKeyInit(&entry[0],
-				Anum_pg_largeobject_metadata_oid,
-				BTEqualStrategyNumber, F_OIDEQ,
-				ObjectIdGetDatum(lobj_oid));
-
-	scan = systable_beginscan(pg_lo_meta,
-							  LargeObjectMetadataOidIndexId, true,
-							  NULL, 1, entry);
-
-	tuple = systable_getnext(scan);
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("large object %u does not exist", lobj_oid)));
-
-	ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner;
-
-	systable_endscan(scan);
-	table_close(pg_lo_meta, AccessShareLock);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a namespace (specified by OID).
- */
-bool
-pg_namespace_ownercheck(Oid nsp_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nsp_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_SCHEMA),
-				 errmsg("schema with OID %u does not exist", nsp_oid)));
-
-	ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a tablespace (specified by OID).
- */
-bool
-pg_tablespace_ownercheck(Oid spc_oid, Oid roleid)
-{
-	HeapTuple	spctuple;
-	Oid			spcowner;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	/* Search syscache for pg_tablespace */
-	spctuple = SearchSysCache1(TABLESPACEOID, ObjectIdGetDatum(spc_oid));
-	if (!HeapTupleIsValid(spctuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("tablespace with OID %u does not exist", spc_oid)));
-
-	spcowner = ((Form_pg_tablespace) GETSTRUCT(spctuple))->spcowner;
-
-	ReleaseSysCache(spctuple);
-
-	return has_privs_of_role(roleid, spcowner);
-}
-
-/*
- * Ownership check for an operator class (specified by OID).
- */
-bool
-pg_opclass_ownercheck(Oid opc_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(CLAOID, ObjectIdGetDatum(opc_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("operator class with OID %u does not exist",
-						opc_oid)));
-
-	ownerId = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for an operator family (specified by OID).
- */
-bool
-pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opf_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("operator family with OID %u does not exist",
-						opf_oid)));
-
-	ownerId = ((Form_pg_opfamily) GETSTRUCT(tuple))->opfowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a tag (specified by OID).
- */
-bool
-pg_tag_ownercheck(Oid tag_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(TAGOID, ObjectIdGetDatum(tag_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("tag with OID %u does not exist",
-						tag_oid)));
-
-	ownerId = ((Form_pg_tag) GETSTRUCT(tuple))->tagowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a text search dictionary (specified by OID).
- */
-bool
-pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dict_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("text search dictionary with OID %u does not exist",
-						dict_oid)));
-
-	ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a text search configuration (specified by OID).
- */
-bool
-pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfg_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("text search configuration with OID %u does not exist",
-						cfg_oid)));
-
-	ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a foreign-data wrapper (specified by OID).
- */
-bool
-pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(srv_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("foreign-data wrapper with OID %u does not exist",
-						srv_oid)));
-
-	ownerId = ((Form_pg_foreign_data_wrapper) GETSTRUCT(tuple))->fdwowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a foreign server (specified by OID).
- */
-bool
-pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srv_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("foreign server with OID %u does not exist",
-						srv_oid)));
-
-	ownerId = ((Form_pg_foreign_server) GETSTRUCT(tuple))->srvowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a storage server (specified by OID).
- */
-bool
-gp_storage_server_ownercheck(Oid srv_oid, Oid roleid)
+gp_storage_server_ownercheck(Oid srv_oid, Oid roleid)
 {
 	HeapTuple	tuple;
 	Oid			ownerId;
@@ -5502,8 +4596,8 @@ gp_storage_server_ownercheck(Oid srv_oid, Oid roleid)
 	if (!HeapTupleIsValid(tuple))
 		ereport(ERROR,
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("storage server with OID %u does not exist",
-					   srv_oid)));
+						errmsg("storage server with OID %u does not exist",
+							   srv_oid)));
 
 	ownerId = ((Form_gp_storage_server) GETSTRUCT(tuple))->srvowner;
 
@@ -5529,8 +4623,8 @@ pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
 	if (!HeapTupleIsValid(tuple))
 		ereport(ERROR,
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("event trigger with OID %u does not exist",
-						et_oid)));
+						errmsg("event trigger with OID %u does not exist",
+							   et_oid)));
 
 	ownerId = ((Form_pg_event_trigger) GETSTRUCT(tuple))->evtowner;
 
@@ -5539,240 +4633,6 @@ pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
 	return has_privs_of_role(roleid, ownerId);
 }
 
-/*
- * Ownership check for a database (specified by OID).
- */
-bool
-pg_database_ownercheck(Oid db_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			dba;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(db_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_DATABASE),
-				 errmsg("database with OID %u does not exist", db_oid)));
-
-	dba = ((Form_pg_database) GETSTRUCT(tuple))->datdba;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, dba);
-}
-
-/*
- * Ownership check for a collation (specified by OID).
- */
-bool
-pg_collation_ownercheck(Oid coll_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(COLLOID, ObjectIdGetDatum(coll_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("collation with OID %u does not exist", coll_oid)));
-
-	ownerId = ((Form_pg_collation) GETSTRUCT(tuple))->collowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a conversion (specified by OID).
- */
-bool
-pg_conversion_ownercheck(Oid conv_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(CONVOID, ObjectIdGetDatum(conv_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("conversion with OID %u does not exist", conv_oid)));
-
-	ownerId = ((Form_pg_conversion) GETSTRUCT(tuple))->conowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for an extension (specified by OID).
- */
-bool
-pg_extension_ownercheck(Oid ext_oid, Oid roleid)
-{
-	Relation	pg_extension;
-	ScanKeyData entry[1];
-	SysScanDesc scan;
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	/* There's no syscache for pg_extension, so do it the hard way */
-	pg_extension = table_open(ExtensionRelationId, AccessShareLock);
-
-	ScanKeyInit(&entry[0],
-				Anum_pg_extension_oid,
-				BTEqualStrategyNumber, F_OIDEQ,
-				ObjectIdGetDatum(ext_oid));
-
-	scan = systable_beginscan(pg_extension,
-							  ExtensionOidIndexId, true,
-							  NULL, 1, entry);
-
-	tuple = systable_getnext(scan);
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("extension with OID %u does not exist", ext_oid)));
-
-	ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner;
-
-	systable_endscan(scan);
-	table_close(pg_extension, AccessShareLock);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a publication (specified by OID).
- */
-bool
-pg_publication_ownercheck(Oid pub_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pub_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("publication with OID %u does not exist", pub_oid)));
-
-	ownerId = ((Form_pg_publication) GETSTRUCT(tuple))->pubowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a subscription (specified by OID).
- */
-bool
-pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(sub_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("subscription with OID %u does not exist", sub_oid)));
-
-	ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
-
-	ReleaseSysCache(tuple);
-
-	return has_privs_of_role(roleid, ownerId);
-}
-
-/*
- * Ownership check for a statistics object (specified by OID).
- */
-bool
-pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid)
-{
-	HeapTuple	tuple;
-	Oid			ownerId;
-
-	/* Superusers bypass all permission checking. */
-	if (superuser_arg(roleid))
-		return true;
-
-	tuple = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(stat_oid));
-	if (!HeapTupleIsValid(tuple))
-		ereport(ERROR,
-				(errcode(ERRCODE_UNDEFINED_OBJECT),
-				 errmsg("statistics object with OID %u does not exist",
-						stat_oid)));
-
-	ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->stxowner;
-
-	ReleaseSysCache(tuple);
-=======
-	{
-		/* for catalogs without an appropriate syscache */
-		Relation	rel;
-		ScanKeyData entry[1];
-		SysScanDesc scan;
-		HeapTuple	tuple;
-		bool		isnull;
-
-		rel = table_open(classid, AccessShareLock);
-
-		ScanKeyInit(&entry[0],
-					get_object_attnum_oid(classid),
-					BTEqualStrategyNumber, F_OIDEQ,
-					ObjectIdGetDatum(objectid));
-
-		scan = systable_beginscan(rel,
-								  get_object_oid_index(classid), true,
-								  NULL, 1, entry);
-
-		tuple = systable_getnext(scan);
-		if (!HeapTupleIsValid(tuple))
-			ereport(ERROR,
-					(errcode(ERRCODE_UNDEFINED_OBJECT),
-					 errmsg("%s with OID %u does not exist", get_object_class_descr(classid), objectid)));
-
-		ownerId = DatumGetObjectId(heap_getattr(tuple,
-												get_object_attnum_owner(classid),
-												RelationGetDescr(rel),
-												&isnull));
-		Assert(!isnull);
-
-		systable_endscan(scan);
-		table_close(rel, AccessShareLock);
-	}
->>>>>>> REL_16_9
-
-	return has_privs_of_role(roleid, ownerId);
-}
 
 /*
  * Ownership check for an external protocol (specified by OID).
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 5c620d9e95e..0b723b8e7d3 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -632,7 +632,6 @@ IsSharedRelation(Oid relationId)
 }
 
 /*
-<<<<<<< HEAD
  * OIDs for catalog object are normally allocated in the master, and
  * executor nodes should just use the OIDs passed by the master. But
  * there are some exceptions.
@@ -681,7 +680,8 @@ RelationNeedsSynchronizedOIDs(Relation relation)
 	}
 	return false;
 }
-=======
+
+/*
  * IsPinnedObject
  *		Given the class + OID identity of a database object, report whether
  *		it is "pinned", that is not droppable because the system requires it.
@@ -743,8 +743,6 @@ IsPinnedObject(Oid classId, Oid objectId)
 	return true;
 }
 
->>>>>>> REL_16_9
-
 /*
  * GetNewOidWithIndex
  *		Generate a new OID that is unique within the system relation.
@@ -878,7 +876,7 @@ GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
 }
 
 static bool
-GpCheckRelFileCollision(RelFileNodeBackend rnode)
+GpCheckRelFileCollision(RelFileLocatorBackend rnode)
 {
 	char	   *rpath;
 	bool		collides;
@@ -912,13 +910,9 @@ GpCheckRelFileCollision(RelFileNodeBackend rnode)
  * If the relfilenumber will also be used as the relation's OID, pass the
  * opened pg_class catalog, and this routine will guarantee that the result
  * is also an unused OID within pg_class.  If the result is to be used only
-<<<<<<< HEAD
- * as a relfilenode for an existing relation, pass NULL for pg_class.
+ * as a relfilenumber for an existing relation, pass NULL for pg_class.
  * (in GPDB, 'pg_class' is unused, there is a different mechanism to avoid
  * clashes, across the whole cluster.)
-=======
- * as a relfilenumber for an existing relation, pass NULL for pg_class.
->>>>>>> REL_16_9
  *
  * As with GetNewOidWithIndex(), there is some theoretical risk of a race
  * condition, but it doesn't seem worth worrying about.
@@ -929,12 +923,7 @@ GpCheckRelFileCollision(RelFileNodeBackend rnode)
 RelFileNumber
 GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
 {
-<<<<<<< HEAD
-	RelFileNodeBackend rnode;
-=======
 	RelFileLocatorBackend rlocator;
-	char	   *rpath;
->>>>>>> REL_16_9
 	bool		collides;
 	BackendId	backend;
 
@@ -979,22 +968,10 @@ GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
 	{
         CHECK_FOR_INTERRUPTS();
 
-<<<<<<< HEAD
         /* Generate the Relfilenode */
-        rnode.node.relNode = GetNewSegRelfilenode();
-
-		collides = GpCheckRelFileCollision(rnode);
-=======
-		/* Generate the OID */
-		if (pg_class)
-			rlocator.locator.relNumber = GetNewOidWithIndex(pg_class, ClassOidIndexId,
-															Anum_pg_class_oid);
-		else
-			rlocator.locator.relNumber = GetNewObjectId();
+		rlocator.locator.relNumber = GetNewSegRelfilenode();
 
-		/* Check for existing file of same name */
-		rpath = relpath(rlocator, MAIN_FORKNUM);
->>>>>>> REL_16_9
+		collides = GpCheckRelFileCollision(rlocator);
 
 		if (!collides && rnode.node.spcNode != GLOBALTABLESPACE_OID)
 		{
@@ -1015,13 +992,9 @@ GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
 		}
 	} while (collides);
 
-<<<<<<< HEAD
-	elog(DEBUG1, "Calling GetNewRelFileNode returns new relfilenode = %u", rnode.node.relNode);
+	elog(DEBUG1, "Calling GetNewRelFileNode returns new relfilenode = %u", rlocator.locator.relNumber);
 
-	return rnode.node.relNode;
-=======
 	return rlocator.locator.relNumber;
->>>>>>> REL_16_9
 }
 
 /*
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index d9e6e740678..f48824d9edc 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -88,12 +88,9 @@
 #include "commands/taskcmds.h"
 #include "commands/trigger.h"
 #include "commands/typecmds.h"
-<<<<<<< HEAD
 #include "foreign/foreign.h"
-=======
 #include "funcapi.h"
 #include "miscadmin.h"
->>>>>>> REL_16_9
 #include "nodes/nodeFuncs.h"
 #include "parser/parsetree.h"
 #include "rewrite/rewriteRemove.h"
@@ -1194,7 +1191,6 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
 
 			if (otherDesc)
 			{
-<<<<<<< HEAD
 				if (msglevel == NOTICE && Gp_role == GP_ROLE_EXECUTE)
 				{
 					ereport(DEBUG1,
@@ -1221,25 +1217,6 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
 									 objDesc, otherDesc);
 					pfree(otherDesc);
 				}
-=======
-				if (numReportedClient < MAX_REPORTED_DEPS)
-				{
-					/* separate entries with a newline */
-					if (clientdetail.len != 0)
-						appendStringInfoChar(&clientdetail, '\n');
-					appendStringInfo(&clientdetail, _("%s depends on %s"),
-									 objDesc, otherDesc);
-					numReportedClient++;
-				}
-				else
-					numNotReportedClient++;
-				/* separate entries with a newline */
-				if (logdetail.len != 0)
-					appendStringInfoChar(&logdetail, '\n');
-				appendStringInfo(&logdetail, _("%s depends on %s"),
-								 objDesc, otherDesc);
-				pfree(otherDesc);
->>>>>>> REL_16_9
 			}
 			else
 				numNotReportedClient++;
@@ -1621,7 +1598,6 @@ doDeletion(const ObjectAddress *object, int flags)
 			RemovePublicationById(object->objectId);
 			break;
 
-<<<<<<< HEAD
 		case OCLASS_SCHEMA:
 			RemoveSchemaById(object->objectId);
 			/*
@@ -1639,8 +1615,6 @@ doDeletion(const ObjectAddress *object, int flags)
 			RemoveMatviewAuxEntry(object->objectId);
 			break;
 
-=======
->>>>>>> REL_16_9
 		case OCLASS_CAST:
 		case OCLASS_COLLATION:
 		case OCLASS_CONVERSION:
@@ -1658,10 +1632,7 @@ doDeletion(const ObjectAddress *object, int flags)
 		case OCLASS_USER_MAPPING:
 		case OCLASS_DEFACL:
 		case OCLASS_EVENT_TRIGGER:
-<<<<<<< HEAD
 		case OCLASS_EXTPROTOCOL:
-=======
->>>>>>> REL_16_9
 		case OCLASS_TRANSFORM:
 		case OCLASS_ROLE_MEMBERSHIP:
 			DropObjectById(object);
@@ -1674,16 +1645,13 @@ doDeletion(const ObjectAddress *object, int flags)
 		case OCLASS_DATABASE:
 		case OCLASS_TBLSPACE:
 		case OCLASS_SUBSCRIPTION:
-<<<<<<< HEAD
 		case OCLASS_PROFILE:
 		case OCLASS_PASSWORDHISTORY:
 		case OCLASS_STORAGE_SERVER:
 		case OCLASS_STORAGE_USER_MAPPING:
 		case OCLASS_TAG:
 		case OCLASS_TAG_DESCRIPTION:
-=======
 		case OCLASS_PARAMETER_ACL:
->>>>>>> REL_16_9
 			elog(ERROR, "global objects cannot be deleted by doDeletion");
 			break;
 
@@ -3121,7 +3089,6 @@ getObjectClass(const ObjectAddress *object)
 		case EventTriggerRelationId:
 			return OCLASS_EVENT_TRIGGER;
 
-<<<<<<< HEAD
 		case ExtprotocolRelationId:
 			Assert(object->objectSubId == 0);
 			return OCLASS_EXTPROTOCOL;
@@ -3131,10 +3098,9 @@ getObjectClass(const ObjectAddress *object)
 
 		case PasswordHistoryRelationId:
 			return OCLASS_PASSWORDHISTORY;
-=======
+
 		case ParameterAclRelationId:
 			return OCLASS_PARAMETER_ACL;
->>>>>>> REL_16_9
 
 		case PolicyRelationId:
 			return OCLASS_POLICY;
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index d609f15b464..dc1a71cdb1b 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -3,13 +3,9 @@
  * index.c
  *	  code to create and destroy POSTGRES index relations
  *
-<<<<<<< HEAD
  * Portions Copyright (c) 2006-2009, Greenplum inc
  * Portions Copyright (c) 2012-Present VMware, Inc. or its affiliates.
- * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
-=======
  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
->>>>>>> REL_16_9
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
@@ -1045,45 +1041,10 @@ index_create_internal(Relation heapRelation,
 	 */
 	if (!OidIsValid(indexRelationId))
 	{
-<<<<<<< HEAD
 		indexRelationId = GetNewOidForRelation(pg_class, ClassOidIndexId,
 											   Anum_pg_class_oid,
 											   (char *) indexRelationName,
 											   namespaceId);
-=======
-		/* Use binary-upgrade override for pg_class.oid and relfilenumber */
-		if (IsBinaryUpgrade)
-		{
-			if (!OidIsValid(binary_upgrade_next_index_pg_class_oid))
-				ereport(ERROR,
-						(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-						 errmsg("pg_class index OID value not set when in binary upgrade mode")));
-
-			indexRelationId = binary_upgrade_next_index_pg_class_oid;
-			binary_upgrade_next_index_pg_class_oid = InvalidOid;
-
-			/* Override the index relfilenumber */
-			if ((relkind == RELKIND_INDEX) &&
-				(!RelFileNumberIsValid(binary_upgrade_next_index_pg_class_relfilenumber)))
-				ereport(ERROR,
-						(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-						 errmsg("index relfilenumber value not set when in binary upgrade mode")));
-			relFileNumber = binary_upgrade_next_index_pg_class_relfilenumber;
-			binary_upgrade_next_index_pg_class_relfilenumber = InvalidRelFileNumber;
-
-			/*
-			 * Note that we want create_storage = true for binary upgrade. The
-			 * storage we create here will be replaced later, but we need to
-			 * have something on disk in the meanwhile.
-			 */
-			Assert(create_storage);
-		}
-		else
-		{
-			indexRelationId =
-				GetNewRelFileNumber(tableSpaceId, pg_class, relpersistence);
-		}
->>>>>>> REL_16_9
 	}
 
 	/*
@@ -3094,7 +3055,6 @@ index_update_stats(Relation rel,
 		dirty = true;
 	}
 
-<<<<<<< HEAD
 	if (reltuples >= 0 && Gp_role != GP_ROLE_DISPATCH)
 	{
 		BlockNumber relpages;
@@ -3110,10 +3070,6 @@ index_update_stats(Relation rel,
 		else					/* don't bother for indexes */
 			relallvisible = 0;
 
-=======
-	if (update_stats)
-	{
->>>>>>> REL_16_9
 		if (rd_rel->relpages != (int32) relpages)
 		{
 			rd_rel->relpages = (int32) relpages;
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index c86dd1ba754..ae42e8cde65 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -4644,7 +4644,6 @@ RemoveTempRelationsCallback(int code, Datum arg)
 			ObjectAddress object;
 			ObjectAddress toastobject;
 
-<<<<<<< HEAD
 			object.classId = NamespaceRelationId;
 			object.objectId = myTempNamespace;
 			object.objectSubId = 0;
@@ -4661,8 +4660,6 @@ RemoveTempRelationsCallback(int code, Datum arg)
 				 myTempNamespace); 
 		}
 
-=======
->>>>>>> REL_16_9
 		PopActiveSnapshot();
 		CommitTransactionCommand();
 	}
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 9d6346b8a56..22d918172a1 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -49,12 +49,9 @@
 #include "catalog/pg_opclass.h"
 #include "catalog/pg_operator.h"
 #include "catalog/pg_opfamily.h"
-<<<<<<< HEAD
 #include "catalog/pg_password_history.h"
-#include "catalog/pg_profile.h"
-=======
 #include "catalog/pg_parameter_acl.h"
->>>>>>> REL_16_9
+#include "catalog/pg_profile.h"
 #include "catalog/pg_policy.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_publication.h"
@@ -1169,11 +1166,8 @@ get_object_address(ObjectType objtype, Node *object,
 			case OBJECT_FDW:
 			case OBJECT_FOREIGN_SERVER:
 			case OBJECT_EVENT_TRIGGER:
-<<<<<<< HEAD
 			case OBJECT_EXTPROTOCOL:
-=======
 			case OBJECT_PARAMETER_ACL:
->>>>>>> REL_16_9
 			case OBJECT_ACCESS_METHOD:
 			case OBJECT_PUBLICATION:
 			case OBJECT_SUBSCRIPTION:
@@ -2441,11 +2435,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
 			/* FALLTHROUGH */
 		case OBJECT_DOMCONSTRAINT:
 		case OBJECT_CAST:
-<<<<<<< HEAD
-		case OBJECT_USER_MAPPING:
 		case OBJECT_STORAGE_USER_MAPPING:
-=======
->>>>>>> REL_16_9
 		case OBJECT_PUBLICATION_REL:
 		case OBJECT_DEFACL:
 		case OBJECT_TRANSFORM:
@@ -2678,49 +2668,14 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
 		case OBJECT_SCHEMA:
 		case OBJECT_SUBSCRIPTION:
 		case OBJECT_TABLESPACE:
+		case OBJECT_STORAGE_SERVER:
+		case OBJECT_TAG:
 			if (!object_ownercheck(address.classId, address.objectId, roleid))
 				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
 							   strVal(object));
 			break;
 		case OBJECT_COLLATION:
 		case OBJECT_CONVERSION:
-<<<<<<< HEAD
-			if (!pg_conversion_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   NameListToString(castNode(List, object)));
-			break;
-		case OBJECT_EXTENSION:
-			if (!pg_extension_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-		case OBJECT_FDW:
-			if (!pg_foreign_data_wrapper_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-		case OBJECT_FOREIGN_SERVER:
-			if (!pg_foreign_server_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-		case OBJECT_STORAGE_SERVER:
-			if (!gp_storage_server_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-		case OBJECT_EVENT_TRIGGER:
-			if (!pg_event_trigger_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-		case OBJECT_LANGUAGE:
-			if (!pg_language_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-=======
->>>>>>> REL_16_9
 		case OBJECT_OPCLASS:
 		case OBJECT_OPFAMILY:
 		case OBJECT_STATISTIC_EXT:
@@ -2764,29 +2719,6 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
 					aclcheck_error_type(ACLCHECK_NOT_OWNER, typeid);
 			}
 			break;
-<<<<<<< HEAD
-		case OBJECT_TABLESPACE:
-			if (!pg_tablespace_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   strVal((Value *) object));
-			break;
-		case OBJECT_TAG:
-			if (!pg_tag_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-				   			   strVal((Value *) object));
-			break;
-		case OBJECT_TSDICTIONARY:
-			if (!pg_ts_dict_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   NameListToString(castNode(List, object)));
-			break;
-		case OBJECT_TSCONFIGURATION:
-			if (!pg_ts_config_ownercheck(address.objectId, roleid))
-				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
-							   NameListToString(castNode(List, object)));
-			break;
-=======
->>>>>>> REL_16_9
 		case OBJECT_ROLE:
 
 			/*
@@ -2830,21 +2762,17 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
 		case OBJECT_TSPARSER:
 		case OBJECT_TSTEMPLATE:
 		case OBJECT_ACCESS_METHOD:
-<<<<<<< HEAD
+		case OBJECT_PARAMETER_ACL:
 		case OBJECT_RESQUEUE:
 		case OBJECT_RESGROUP:
-=======
-		case OBJECT_PARAMETER_ACL:
->>>>>>> REL_16_9
 			/* We treat these object types as being owned by superusers */
 			if (!superuser_arg(roleid))
 				ereport(ERROR,
 						(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
 						 errmsg("must be superuser")));
 			break;
-<<<<<<< HEAD
 		case OBJECT_STATISTIC_EXT:
-			if (!pg_statistics_object_ownercheck(address.objectId, roleid))
+			if (!object_ownercheck(STATEXTOID, address.objectId, roleid))
 				aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
 							   NameListToString(castNode(List, object)));
 			break;
@@ -2854,7 +2782,6 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
 				ereport(ERROR,
 						(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
 						 errmsg("must be superuser")));
-=======
 		case OBJECT_AMOP:
 		case OBJECT_AMPROC:
 		case OBJECT_DEFAULT:
@@ -2864,7 +2791,6 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
 		case OBJECT_USER_MAPPING:
 			/* These are currently not supported or don't make sense here. */
 			elog(ERROR, "unsupported object type: %d", (int) objtype);
->>>>>>> REL_16_9
 			break;
 	}
 }
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index ae2f776057f..02e0ce71a07 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -181,11 +181,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
  * of the current extension.  In the latter case we can skip checking whether
  * it is already a member of any extension.
  *
-<<<<<<< HEAD
- * Note: isReplace = true is typically used when updating a object in
-=======
  * Note: isReplace = true is typically used when updating an object in
->>>>>>> REL_16_9
  * CREATE OR REPLACE and similar commands.  We used to allow the target
  * object to not already be an extension member, instead silently absorbing
  * it into the current extension.  However, this was both error-prone
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index f009e143ee3..fd54ea7dda2 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -41,10 +41,7 @@
 #include "parser/analyze.h"
 #include "parser/parse_coerce.h"
 #include "parser/parse_type.h"
-<<<<<<< HEAD
-=======
 #include "pgstat.h"
->>>>>>> REL_16_9
 #include "rewrite/rewriteHandler.h"
 #include "tcop/pquery.h"
 #include "tcop/tcopprot.h"
@@ -1100,14 +1097,8 @@ function_parse_error_transpose(const char *prosrc)
 	}
 
 	/* We can get the original query text from the active portal (hack...) */
-<<<<<<< HEAD
 	/* Assert(ActivePortal && PortalGetStatus(ActivePortal) == PORTAL_ACTIVE); */
 	queryText = ActivePortal->sourceText;
-=======
-	if (ActivePortal && ActivePortal->status == PORTAL_ACTIVE)
-	{
-		const char *queryText = ActivePortal->sourceText;
->>>>>>> REL_16_9
 
 		/* Try to locate the prosrc in the original text */
 		newerrposition = match_prosrc_to_query(prosrc, queryText,
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 636a8c12468..47f7e45bd83 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -45,9 +45,7 @@
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
-<<<<<<< HEAD
 #include "catalog/oid_dispatch.h"
-=======
 /* Records association between publication and published table */
 typedef struct
 {
@@ -58,7 +56,6 @@ typedef struct
 
 static void publication_translate_columns(Relation targetrel, List *columns,
 										  int *natts, AttrNumber **attrs);
->>>>>>> REL_16_9
 
 /*
  * Check if relation can be in given publication and throws appropriate
@@ -153,50 +150,7 @@ is_publishable_class(Oid relid, Form_pg_class reltuple)
 }
 
 /*
-<<<<<<< HEAD
- * Filter out the partitions whose parent tables were also specified in
- * the publication.
- */
-static List *
-filter_partitions(List *relids)
-{
-	List	   *result = NIL;
-	ListCell   *lc;
-	ListCell   *lc2;
-
-	foreach(lc, relids)
-	{
-		bool		skip = false;
-		List	   *ancestors = NIL;
-		Oid			relid = lfirst_oid(lc);
-
-		if (get_rel_relispartition(relid))
-			ancestors = get_partition_ancestors(relid);
-
-		foreach(lc2, ancestors)
-		{
-			Oid			ancestor = lfirst_oid(lc2);
-
-			/* Check if the parent table exists in the published table list. */
-			if (list_member_oid(relids, ancestor))
-			{
-				skip = true;
-				break;
-			}
-		}
-
-		if (!skip)
-			result = lappend_oid(result, relid);
-	}
-
-	return result;
-}
-
-/*
- * Another variant of this, taking a Relation.
-=======
  * Another variant of is_publishable_class(), taking a Relation.
->>>>>>> REL_16_9
  */
 bool
 is_publishable_relation(Relation rel)
@@ -227,8 +181,6 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS)
 }
 
 /*
-<<<<<<< HEAD
-=======
  * Returns true if the ancestor is in the list of published relations.
  * Otherwise, returns false.
  */
@@ -314,7 +266,6 @@ is_schema_publication(Oid pubid)
 }
 
 /*
->>>>>>> REL_16_9
  * Gets the relations based on the publication partition option for a specified
  * relation.
  */
@@ -350,8 +301,6 @@ GetPubPartitionOptionRelations(List *result, PublicationPartOpt pub_partopt,
 
 	return result;
 }
-<<<<<<< HEAD
-=======
 
 /*
  * Returns the relid of the topmost ancestor that is published via this
@@ -407,7 +356,6 @@ GetTopMostAncestorInPublication(Oid puboid, List *ancestors, int *ancestor_level
 
 	return topmost_relid;
 }
->>>>>>> REL_16_9
 
 /*
  * Insert new publication / relation mapping.
@@ -465,16 +413,10 @@ publication_add_relation(Oid pubid, PublicationRelInfo *pri,
 	memset(values, 0, sizeof(values));
 	memset(nulls, false, sizeof(nulls));
 
-<<<<<<< HEAD
-	prrelid = GetNewOidForPublicationRel(rel, PublicationRelObjectIndexId,
+	pubreloid = GetNewOidForPublicationRel(rel, PublicationRelObjectIndexId,
 										 Anum_pg_publication_rel_oid,
 										 relid, pubid);
-	values[Anum_pg_publication_rel_oid - 1] = ObjectIdGetDatum(prrelid);
-=======
-	pubreloid = GetNewOidWithIndex(rel, PublicationRelObjectIndexId,
-								   Anum_pg_publication_rel_oid);
 	values[Anum_pg_publication_rel_oid - 1] = ObjectIdGetDatum(pubreloid);
->>>>>>> REL_16_9
 	values[Anum_pg_publication_rel_prpubid - 1] =
 		ObjectIdGetDatum(pubid);
 	values[Anum_pg_publication_rel_prrelid - 1] =
@@ -537,8 +479,6 @@ publication_add_relation(Oid pubid, PublicationRelInfo *pri,
 											relid);
 
 	InvalidatePublicationRels(relids);
-<<<<<<< HEAD
-=======
 
 	return myself;
 }
@@ -745,7 +685,6 @@ publication_add_schema(Oid pubid, Oid schemaid, bool if_not_exists)
 	schemaRels = GetSchemaPublicationRelations(schemaid,
 											   PUBLICATION_PART_ALL);
 	InvalidatePublicationRels(schemaRels);
->>>>>>> REL_16_9
 
 	return myself;
 }
@@ -1211,29 +1150,6 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
 		 * data of the child table to be double-published on the subscriber
 		 * side.
 		 */
-<<<<<<< HEAD
-		if (publication->alltables)
-			tables = GetAllTablesPublicationRelations(publication->pubviaroot);
-		else
-		{
-			tables = GetPublicationRelations(publication->oid,
-											 publication->pubviaroot ?
-											 PUBLICATION_PART_ROOT :
-											 PUBLICATION_PART_LEAF);
-
-			/*
-			 * If the publication publishes partition changes via their
-			 * respective root partitioned tables, we must exclude partitions
-			 * in favor of including the root partitioned tables. Otherwise,
-			 * the function could return both the child and parent tables
-			 * which could cause data of the child table to be
-			 * double-published on the subscriber side.
-			 */
-			if (publication->pubviaroot)
-				tables = filter_partitions(tables);
-		}
-		funcctx->user_fctx = (void *) tables;
-=======
 		if (viaroot)
 			filter_partitions(table_infos);
 
@@ -1250,7 +1166,6 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
 
 		funcctx->tuple_desc = BlessTupleDesc(tupdesc);
 		funcctx->user_fctx = (void *) table_infos;
->>>>>>> REL_16_9
 
 		MemoryContextSwitchTo(oldcontext);
 	}
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index aa8d017449a..109157a8b3e 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -43,7 +43,6 @@
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
-<<<<<<< HEAD
 #include "catalog/gp_indexing.h"
 #include "catalog/pg_type_encoding.h"
 #include "cdb/cdbvars.h"
@@ -51,8 +50,6 @@
 /* GPDB_14_MERGE_FIXME: Do we need to keep binary_upgrade_next_pg_type_oid
  * for binary upgrade?
  */
-=======
->>>>>>> REL_16_9
 /* Potentially set by pg_upgrade_support functions */
 Oid			binary_upgrade_next_pg_type_oid = InvalidOid;
 
@@ -688,14 +685,6 @@ TypeCreate(Oid newTypeOid,
  * isDependentType is true if this is an implicit array or relation rowtype;
  * that means it doesn't need its own dependencies on owner etc.
  *
-<<<<<<< HEAD
- * If rebuild is true, we remove existing dependencies and rebuild them
- * from scratch.  This is needed for ALTER TYPE, and also when replacing
- * a shell type.  We don't remove an existing extension dependency, though.
- * That means an extension can't absorb a shell type that is free-standing
- * or belongs to another extension, nor ALTER a type that is free-standing or
- * belongs to another extension.
-=======
  * We make an extension-membership dependency if we're in an extension
  * script and makeExtensionDep is true (and isDependentType isn't true).
  * makeExtensionDep should be true when creating a new type or replacing a
@@ -710,7 +699,6 @@ TypeCreate(Oid newTypeOid,
  * type already belongs to the current extension.  That's the behavior we
  * want when replacing a shell type, which is the only case where both flags
  * are true.
->>>>>>> REL_16_9
  */
 void
 GenerateTypeDependencies(HeapTuple typeTuple,
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index be9a3464832..9814aa4eb63 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -290,12 +290,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
 										   true,
 										   true,
 										   OIDOldToast,
-<<<<<<< HEAD
 										   NULL,
 										   /* valid_opts */ false);
-=======
-										   NULL);
->>>>>>> REL_16_9
 	Assert(toast_relid != InvalidOid);
 
 	/* make the toast relation visible, else table_open will fail */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org