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 117fb86d397 Fix some conflicts in commands
117fb86d397 is described below

commit 117fb86d397dbbae548319516ea2341f3f31a7c6
Author: Jinbao Chen <[email protected]>
AuthorDate: Sat Jul 19 16:26:37 2025 +0800

    Fix some conflicts in commands
---
 src/backend/commands/async.c            |   7 -
 src/backend/commands/event_trigger.c    |  12 +-
 src/backend/commands/extension.c        |  13 +-
 src/backend/commands/foreigncmds.c      |   8 +-
 src/backend/commands/functioncmds.c     |  19 +--
 src/backend/commands/portalcmds.c       |  21 ---
 src/backend/commands/schemacmds.c       |  12 +-
 src/backend/commands/sequence.c         |  25 +---
 src/backend/commands/statscmds.c        |  24 ----
 src/backend/commands/subscriptioncmds.c |  28 +---
 src/backend/commands/tablespace.c       | 156 +--------------------
 src/backend/commands/tsearchcmds.c      |   4 +-
 src/backend/commands/user.c             | 236 +++++---------------------------
 13 files changed, 53 insertions(+), 512 deletions(-)

diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 34905885954..767d171d03a 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1237,7 +1237,6 @@ Exec_UnlistenAllCommit(void)
 }
 
 /*
-<<<<<<< HEAD
  * ProcessCompletedNotifies --- nowadays this does nothing
  *
  * This routine used to send signals and handle self-notifies,
@@ -1252,8 +1251,6 @@ ProcessCompletedNotifies(void)
 }
 
 /*
-=======
->>>>>>> REL_16_9
  * Test whether we are actively listening on the given channel name.
  *
  * Note: this function is executed for every notification found in the queue.
@@ -2255,11 +2252,7 @@ asyncQueueAdvanceTail(void)
 static void
 ProcessIncomingNotify(bool flush)
 {
-<<<<<<< HEAD
        bool            client_wait_timeout_enabled;
-=======
-       MemoryContext oldcontext;
->>>>>>> REL_16_9
 
        /* We *must* reset the flag */
        notifyInterruptPending = false;
diff --git a/src/backend/commands/event_trigger.c 
b/src/backend/commands/event_trigger.c
index dd27c769348..f46567a5b0c 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -939,13 +939,10 @@ EventTriggerSupportsObjectType(ObjectType obtype)
                case OBJECT_DATABASE:
                case OBJECT_TABLESPACE:
                case OBJECT_ROLE:
-<<<<<<< HEAD
+               case OBJECT_PARAMETER_ACL:
                case OBJECT_PROFILE:
                case OBJECT_STORAGE_SERVER:
                case OBJECT_STORAGE_USER_MAPPING:
-=======
-               case OBJECT_PARAMETER_ACL:
->>>>>>> REL_16_9
                        /* no support for global objects */
                        return false;
                case OBJECT_EVENT_TRIGGER:
@@ -1030,7 +1027,8 @@ EventTriggerSupportsObjectClass(ObjectClass objclass)
                case OCLASS_DATABASE:
                case OCLASS_TBLSPACE:
                case OCLASS_ROLE:
-<<<<<<< HEAD
+               case OCLASS_ROLE_MEMBERSHIP:
+               case OCLASS_PARAMETER_ACL:
                case OCLASS_PROFILE:
                case OCLASS_PASSWORDHISTORY:
                case OCLASS_MATVIEW_AUX:
@@ -1038,10 +1036,6 @@ EventTriggerSupportsObjectClass(ObjectClass objclass)
                case OCLASS_STORAGE_USER_MAPPING:
                case OCLASS_TAG:
                case OCLASS_TAG_DESCRIPTION:
-=======
-               case OCLASS_ROLE_MEMBERSHIP:
-               case OCLASS_PARAMETER_ACL:
->>>>>>> REL_16_9
                        /* no support for global objects */
                        return false;
                case OCLASS_EVENT_TRIGGER:
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 920b8efe643..41e06471f4e 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -895,12 +895,7 @@ extension_is_trusted(ExtensionControlFile *control)
  *
  * If from_version isn't NULL, it's an update
  *
-<<<<<<< HEAD
- * If stmt isn't NULL, it means that there already has been a Gang of type 
GANGTYPE_PRIMARY_WRITER,
- * and the BEGIN phase of stmt has been executed in every QE in this Gang.
-=======
  * Note: requiredSchemas must be one-for-one with the control->requires list
->>>>>>> REL_16_9
  */
 static void
 execute_extension_script(Node *stmt,
@@ -917,16 +912,13 @@ execute_extension_script(Node *stmt,
        int                     save_nestlevel;
        StringInfoData pathbuf;
        ListCell   *lc;
-<<<<<<< HEAD
+       ListCell   *lc2;
        StringInfoData search_path_buffer;
 
        AssertState(Gp_role != GP_ROLE_EXECUTE);
        AssertImply(Gp_role == GP_ROLE_DISPATCH, stmt != NULL &&
                        (nodeTag(stmt) == T_CreateExtensionStmt || 
nodeTag(stmt) == T_AlterExtensionStmt) &&
                        is_begin_state(stmt));
-=======
-       ListCell   *lc2;
->>>>>>> REL_16_9
 
        /*
         * Enforce superuser-ness if appropriate.  We postpone these checks 
until
@@ -1155,8 +1147,6 @@ execute_extension_script(Node *stmt,
                                                
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                                                 errmsg("invalid character in 
extension \"%s\" schema: must not contain any of \"%s\"",
                                                                control->name, 
quoting_relevant_chars)));
-<<<<<<< HEAD
-=======
                }
 
                /*
@@ -1184,7 +1174,6 @@ execute_extension_script(Node *stmt,
                                                
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                                                 errmsg("invalid character in 
extension \"%s\" schema: must not contain any of \"%s\"",
                                                                reqextname, 
quoting_relevant_chars)));
->>>>>>> REL_16_9
                }
 
                /*
diff --git a/src/backend/commands/foreigncmds.c 
b/src/backend/commands/foreigncmds.c
index 627d2a70d41..e260af42188 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -1641,18 +1641,12 @@ CreateForeignTable(CreateForeignTableStmt *stmt, Oid 
relid, bool skip_permission
         * get the actual FDW for option validation etc.
         */
        server = GetForeignServerByName(stmt->servername, false);
-<<<<<<< HEAD
        if (!skip_permission_check)
        {
-               aclresult = pg_foreign_server_aclcheck(server->serverid, 
ownerId, ACL_USAGE);
+               aclresult = object_aclcheck(ForeignServerRelationId, 
server->serverid, ownerId, ACL_USAGE);
                if (aclresult != ACLCHECK_OK)
                        aclcheck_error(aclresult, OBJECT_FOREIGN_SERVER, 
server->servername);
        }
-=======
-       aclresult = object_aclcheck(ForeignServerRelationId, server->serverid, 
ownerId, ACL_USAGE);
-       if (aclresult != ACLCHECK_OK)
-               aclcheck_error(aclresult, OBJECT_FOREIGN_SERVER, 
server->servername);
->>>>>>> REL_16_9
 
        fdw = GetForeignDataWrapper(server->fdwid);
 
diff --git a/src/backend/commands/functioncmds.c 
b/src/backend/commands/functioncmds.c
index 860d915e372..4e1a542f6be 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1573,13 +1573,9 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt 
*stmt)
                returnsSet = false;
        }
 
-<<<<<<< HEAD
        validate_sql_exec_location(execLocation, returnsSet);
 
-       if (list_length(trftypes_list) > 0)
-=======
        if (trftypes_list != NIL)
->>>>>>> REL_16_9
        {
                ListCell   *lc;
                Datum      *arr;
@@ -1717,12 +1713,9 @@ RemoveFunctionById(Oid funcOid)
 
        table_close(relation, RowExclusiveLock);
 
-<<<<<<< HEAD
        /* Remove anything in pg_proc_callback for this function */
        deleteProcCallbacks(funcOid);
-=======
        pgstat_drop_function(funcOid);
->>>>>>> REL_16_9
 
        /*
         * If there's a pg_aggregate tuple, delete that too.
@@ -1918,7 +1911,6 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
                                                                repl_val, 
repl_null, repl_repl);
        }
        /* DO NOT put more touches of procForm below here; it's now dangling. */
-<<<<<<< HEAD
        /* GPDB_14_MERGE_FIXME: except refetch procForm from new tup? */
 
        if (describe_item)
@@ -1977,8 +1969,6 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
                                                         procForm->prolang);
        validate_sql_exec_location(exec_location,
                                                           procForm->proretset);
-=======
->>>>>>> REL_16_9
 
        /* Do the update */
        CatalogTupleUpdate(rel, &tup->t_self, tup);
@@ -2249,9 +2239,8 @@ CreateCast(CreateCastStmt *stmt)
                        break;
        }
 
-<<<<<<< HEAD
-       myself = CastCreate(sourcetypeid, targettypeid, funcid, castcontext,
-                                               castmethod, DEPENDENCY_NORMAL);
+       myself = CastCreate(sourcetypeid, targettypeid, funcid, incastid, 
outcastid,
+                                               castcontext, castmethod, 
DEPENDENCY_NORMAL);
 
        if (Gp_role == GP_ROLE_DISPATCH)
        {
@@ -2263,10 +2252,6 @@ CreateCast(CreateCastStmt *stmt)
                                                                        NULL);
        }
 
-=======
-       myself = CastCreate(sourcetypeid, targettypeid, funcid, incastid, 
outcastid,
-                                               castcontext, castmethod, 
DEPENDENCY_NORMAL);
->>>>>>> REL_16_9
        return myself;
 }
 
diff --git a/src/backend/commands/portalcmds.c 
b/src/backend/commands/portalcmds.c
index 7bba047a6cf..65e7ef3efa0 100644
--- a/src/backend/commands/portalcmds.c
+++ b/src/backend/commands/portalcmds.c
@@ -9,13 +9,9 @@
  * storage management for portals (but doesn't run any queries in them).
  *
  *
-<<<<<<< HEAD
  * Portions Copyright (c) 2006-2008, 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
  *
  *
@@ -518,11 +514,7 @@ PersistHoldablePortal(Portal portal)
                                                                                
NULL);
 
                /* Fetch the result set into the tuplestore */
-<<<<<<< HEAD
-               ExecutorRun(queryDesc, direction, 0L, false);
-=======
                ExecutorRun(queryDesc, direction, 0, false);
->>>>>>> REL_16_9
 
                queryDesc->dest->rDestroy(queryDesc->dest);
                queryDesc->dest = NULL;
@@ -561,7 +553,6 @@ PersistHoldablePortal(Portal portal)
                        {
                                tuplestore_rescan(portal->holdStore);
 
-<<<<<<< HEAD
                                /*
                                 * In the no-scroll case, the start of the 
tuplestore is exactly
                                 * where we want to be, so no repositioning is 
wanted.
@@ -573,18 +564,6 @@ PersistHoldablePortal(Portal portal)
                                                                                
           true))
                                                elog(ERROR, "unexpected end of 
tuple stream");
                                }
-=======
-                       /*
-                        * In the no-scroll case, the start of the tuplestore 
is exactly
-                        * where we want to be, so no repositioning is wanted.
-                        */
-                       if (portal->cursorOptions & CURSOR_OPT_SCROLL)
-                       {
-                               if (!tuplestore_skiptuples(portal->holdStore,
-                                                                               
   portal->portalPos,
-                                                                               
   true))
-                                       elog(ERROR, "unexpected end of tuple 
stream");
->>>>>>> REL_16_9
                        }
                }
        }
diff --git a/src/backend/commands/schemacmds.c 
b/src/backend/commands/schemacmds.c
index 3cc448c7e51..a900f9dc755 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -3,13 +3,9 @@
  * schemacmds.c
  *       schema creation/manipulation commands
  *
-<<<<<<< HEAD
  * Portions Copyright (c) 2005-2010, 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
  *
  * IDENTIFICATION
@@ -78,11 +74,8 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char 
*queryString,
        AclResult       aclresult;
        ObjectAddress address;
        StringInfoData pathbuf;
-<<<<<<< HEAD
-       bool            shouldDispatch = (Gp_role == GP_ROLE_DISPATCH && 
+       bool            shouldDispatch = (Gp_role == GP_ROLE_DISPATCH &&
                                                                  
!IsBootstrapProcessingMode());
-=======
->>>>>>> REL_16_9
 
        /*
         * GPDB: Creation of temporary namespaces is a special case. This 
statement
@@ -186,7 +179,6 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char 
*queryString,
                                                        schemaName)));
                        return InvalidOid;
                }
-<<<<<<< HEAD
        }
 
        /* Create the schema's namespace */
@@ -246,8 +238,6 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char 
*queryString,
                                                           namespaceId,
                                                           stmt->schemaname);
                }
-=======
->>>>>>> REL_16_9
        }
 
        /*
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 165a88054bd..6876e1c8dfe 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -3,13 +3,9 @@
  * sequence.c
  *       PostgreSQL sequences support code.
  *
-<<<<<<< HEAD
  * Portions Copyright (c) 2005-2008, 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
  *
  *
@@ -37,11 +33,8 @@
 #include "catalog/objectaccess.h"
 #include "catalog/pg_sequence.h"
 #include "catalog/pg_type.h"
-<<<<<<< HEAD
-#include "commands/async.h"
-=======
 #include "catalog/storage_xlog.h"
->>>>>>> REL_16_9
+#include "commands/async.h"
 #include "commands/defrem.h"
 #include "commands/sequence.h"
 #include "commands/tablecmds.h"
@@ -108,13 +101,8 @@ SeqTableKey;
  */
 typedef struct SeqTableData
 {
-<<<<<<< HEAD
-       SeqTableKey     key;                    /* sequence data hash key */
-       Oid             filenode;               /* last seen relfilenode of 
this sequence */
-=======
-       Oid                     relid;                  /* pg_class OID of this 
sequence (hash key) */
+       SeqTableKey     key;                    /* sequence data hash key *//
        RelFileNumber filenumber;       /* last seen relfilenumber of this 
sequence */
->>>>>>> REL_16_9
        LocalTransactionId lxid;        /* xact in which we last did a seq op */
        bool            last_valid;             /* do we have a valid "last" 
value? */
        int64           last;                   /* value last returned by 
nextval */
@@ -181,7 +169,6 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
        bool            pgs_nulls[Natts_pg_sequence];
        int                     i;
 
-<<<<<<< HEAD
        bool shouldDispatch = (Gp_role == GP_ROLE_DISPATCH &&
                                                   ENABLE_DISPATCH() &&
                                                   
!IsBootstrapProcessingMode());
@@ -192,8 +179,6 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                 errmsg("unlogged sequences are not 
supported")));
 
-=======
->>>>>>> REL_16_9
        /*
         * If if_not_exists was given and a relation with the same name already
         * exists, bail out. (Note: we needn't check this when not 
if_not_exists,
@@ -1383,11 +1368,7 @@ init_sequence_internal(Oid _relid, SeqTable *p_elm, 
Relation *p_rel,
         * discard any cached-but-unissued values.  We do not touch the 
currval()
         * state, however.
         */
-<<<<<<< HEAD
-       if (seqrel->rd_rel->relfilenode != elm->filenode && 
called_from_dispatcher)
-=======
-       if (seqrel->rd_rel->relfilenode != elm->filenumber)
->>>>>>> REL_16_9
+       if (seqrel->rd_rel->relfilenode != elm->filenumber && 
called_from_dispatcher)
        {
                elm->filenumber = seqrel->rd_rel->relfilenode;
                elm->cached = elm->last;
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 03bddf19397..d3220849f6a 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -217,16 +217,6 @@ CreateStatistics(CreateStatsStmt *stmt)
         * Convert the expression list to a simple array of attnums, but also 
keep
         * a list of more complex expressions.  While at it, enforce some
         * constraints - we don't allow extended statistics on system 
attributes,
-<<<<<<< HEAD
-        * and we require the data type to have less-than operator.
-        *
-        * There are many ways how to "mask" a simple attribute refenrece as an
-        * expression, for example "(a+0)" etc. We can't possibly detect all of
-        * them, but we handle at least the simple case with attribute in 
parens.
-        * There'll always be a way around this, if the user is determined (like
-        * the "(a+0)" example), but this makes it somewhat consistent with how
-        * indexes treat attributes/expressions.
-=======
         * and we require the data type to have a less-than operator.
         *
         * There are many ways to "mask" a simple attribute reference as an
@@ -235,7 +225,6 @@ CreateStatistics(CreateStatsStmt *stmt)
         * parens. There'll always be a way around this, if the user is 
determined
         * (like the "(a+0)" example), but this makes it somewhat consistent 
with
         * how indexes treat attributes/expressions.
->>>>>>> REL_16_9
         */
        foreach(cell, stmt->exprs)
        {
@@ -276,15 +265,9 @@ CreateStatistics(CreateStatsStmt *stmt)
                        nattnums++;
                        ReleaseSysCache(atttuple);
                }
-<<<<<<< HEAD
-               else if (IsA(selem->expr, Var)) /* column reference in parens */
-               {
-                       Var *var = (Var *) selem->expr;
-=======
                else if (IsA(selem->expr, Var)) /* column reference in parens */
                {
                        Var                *var = (Var *) selem->expr;
->>>>>>> REL_16_9
                        TypeCacheEntry *type;
 
                        /* Disallow use of system attributes in extended stats 
*/
@@ -321,18 +304,11 @@ CreateStatistics(CreateStatsStmt *stmt)
                        while ((k = bms_next_member(attnums, k)) >= 0)
                        {
                                AttrNumber      attnum = k + 
FirstLowInvalidHeapAttributeNumber;
-<<<<<<< HEAD
-                               if (attnum <= 0)
-                                       ereport(ERROR,
-                                               
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                                errmsg("statistics creation on 
system columns is not supported")));
-=======
 
                                if (attnum <= 0)
                                        ereport(ERROR,
                                                        
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                                         errmsg("statistics 
creation on system columns is not supported")));
->>>>>>> REL_16_9
                        }
 
                        /*
diff --git a/src/backend/commands/subscriptioncmds.c 
b/src/backend/commands/subscriptioncmds.c
index 9c93d01959b..2aeb64bc6b8 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -52,12 +52,11 @@
 #include "utils/pg_lsn.h"
 #include "utils/syscache.h"
 
-<<<<<<< HEAD
 #include "catalog/heap.h"
 #include "catalog/oid_dispatch.h"
 #include "cdb/cdbdisp_query.h"
 #include "cdb/cdbvars.h"
-=======
+
 /*
  * Options that can be specified by the user in CREATE/ALTER SUBSCRIPTION
  * command.
@@ -104,7 +103,6 @@ typedef struct SubOpts
        char       *origin;
        XLogRecPtr      lsn;
 } SubOpts;
->>>>>>> REL_16_9
 
 static List *fetch_table_list(WalReceiverConn *wrconn, List *publications);
 static void check_publications_origin(WalReceiverConn *wrconn,
@@ -207,17 +205,10 @@ parse_subscription_options(ParseState *pstate, List 
*stmt_options,
                        opts->slot_name = defGetString(defel);
 
                        /* Setting slot_name = NONE is treated as no slot name. 
*/
-<<<<<<< HEAD
-                       if (strcmp(*slot_name, "none") == 0)
-                               *slot_name = NULL;
-                       else
-                               ReplicationSlotValidateName(*slot_name, ERROR);
-=======
                        if (strcmp(opts->slot_name, "none") == 0)
                                opts->slot_name = NULL;
                        else
                                ReplicationSlotValidateName(opts->slot_name, 
ERROR);
->>>>>>> REL_16_9
                }
                else if (IsSet(supported_opts, SUBOPT_COPY_DATA) &&
                                 strcmp(defel->defname, "copy_data") == 0)
@@ -851,7 +842,6 @@ CreateSubscription(ParseState *pstate, 
CreateSubscriptionStmt *stmt,
 
        table_close(rel, RowExclusiveLock);
 
-<<<<<<< HEAD
        if (Gp_role == GP_ROLE_DISPATCH)
        {
                CdbDispatchUtilityStatement((Node *) stmt,
@@ -868,12 +858,9 @@ CreateSubscription(ParseState *pstate, 
CreateSubscriptionStmt *stmt,
                                                   "CREATE", "SUBSCRIPTION");
        }
 
-       if (enabled)
-=======
        pgstat_create_subscription(subid);
 
        if (opts.enabled)
->>>>>>> REL_16_9
                ApplyLauncherWakeupAtCommit();
 
        ObjectAddressSet(myself, SubscriptionRelationId, subid);
@@ -1359,22 +1346,9 @@ AlterSubscription(ParseState *pstate, 
AlterSubscriptionStmt *stmt,
                                List       *publist;
                                bool            isadd = stmt->kind == 
ALTER_SUBSCRIPTION_ADD_PUBLICATION;
 
-<<<<<<< HEAD
-                               parse_subscription_options(stmt->options,
-                                                                               
   NULL,        /* no "connect" */
-                                                                               
   NULL, NULL,  /* no "enabled" */
-                                                                               
   NULL,        /* no "create_slot" */
-                                                                               
   NULL, NULL,  /* no "slot_name" */
-                                                                               
   &copy_data,
-                                                                               
   NULL,        /* no "synchronous_commit" */
-                                                                               
   &refresh,
-                                                                               
   NULL, NULL,  /* no "binary" */
-                                                                               
   NULL, NULL); /* no "streaming" */
-=======
                                supported_opts = SUBOPT_REFRESH | 
SUBOPT_COPY_DATA;
                                parse_subscription_options(pstate, 
stmt->options,
                                                                                
   supported_opts, &opts);
->>>>>>> REL_16_9
 
                                publist = merge_publications(sub->publications, 
stmt->publication, isadd, stmt->subname);
                                values[Anum_pg_subscription_subpublications - 
1] =
diff --git a/src/backend/commands/tablespace.c 
b/src/backend/commands/tablespace.c
index ce88b10507e..8fe677038d9 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -16,7 +16,6 @@
  * maintain a symbolic-link map in $PGDATA/pg_tblspc. The symlinks are
  * named by tablespace OIDs and point to the actual tablespace directories.
  * There is also a per-cluster version directory in each tablespace.
-<<<<<<< HEAD
  *
  * In GPDB, the "dbid" of the server is also embedded in the path, so that
  * multiple segments running on the host can use the same directory without
@@ -27,12 +26,6 @@
  *
  * The path to the tablespace looks like this:
  *          /path/to/tablespace/<dbid>/GPDB_MAJOR_CATVER/dboid/relfilenode
-=======
- * Thus the full path to an arbitrary file is
- *                     
$PGDATA/pg_tblspc/spcoid/PG_MAJORVER_CATVER/dboid/relfilenumber
- * e.g.
- *                     $PGDATA/pg_tblspc/20981/PG_9.0_201002161/719849/83292814
->>>>>>> REL_16_9
  *
  * There are two tablespaces created at initdb time: pg_global (for shared
  * tables) and pg_default (for everything else).  For backwards compatibility
@@ -48,13 +41,9 @@
  * and munge the system catalogs of the new database.
  *
  *
-<<<<<<< HEAD
  * Portions Copyright (c) 2005-2010 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
  *
  *
@@ -188,14 +177,10 @@ TablespaceCreateDbspace(Oid spcOid, Oid dbOid, bool 
isRedo)
        Assert(OidIsValid(spcOid));
        Assert(OidIsValid(dbOid));
 
-<<<<<<< HEAD
        if (spcNode != DEFAULTTABLESPACE_OID && !isRedo)
                TablespaceLockTuple(spcNode, AccessShareLock, true);
 
-       dir = GetDatabasePath(dbNode, spcNode);
-=======
        dir = GetDatabasePath(dbOid, spcOid);
->>>>>>> REL_16_9
 
        if (stat(dir, &st) < 0)
        {
@@ -286,12 +271,8 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
        char       *location = NULL;
        Oid                     ownerId;
        Datum           newOptions;
-<<<<<<< HEAD
        List       *nonContentOptions = NIL;
        char       *fileHandler = NULL;
-=======
-       bool            in_place;
->>>>>>> REL_16_9
 
        /* Must be superuser */
        if (!superuser())
@@ -446,18 +427,13 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
                                        
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                         errmsg("pg_tablespace OID value not 
set when in binary upgrade mode")));
 
-<<<<<<< HEAD
-       tablespaceoid = GetNewOidForTableSpace(rel, TablespaceOidIndexId,
-                                                                               
   Anum_pg_tablespace_oid,
-                                                                               
   stmt->tablespacename);
-=======
                tablespaceoid = binary_upgrade_next_pg_tablespace_oid;
                binary_upgrade_next_pg_tablespace_oid = InvalidOid;
        }
        else
-               tablespaceoid = GetNewOidWithIndex(rel, TablespaceOidIndexId,
-                                                                               
   Anum_pg_tablespace_oid);
->>>>>>> REL_16_9
+               tablespaceoid = GetNewOidForTableSpace(rel, 
TablespaceOidIndexId,
+                                                                               
           Anum_pg_tablespace_oid,
+                                                                               
           stmt->tablespacename);
        values[Anum_pg_tablespace_oid - 1] = ObjectIdGetDatum(tablespaceoid);
        values[Anum_pg_tablespace_spcname - 1] =
                DirectFunctionCall1(namein, 
CStringGetDatum(stmt->tablespacename));
@@ -792,49 +768,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
         */
        LWLockAcquire(TablespaceCreateLock, LW_EXCLUSIVE);
 
-<<<<<<< HEAD
        ensure_tablespace_directory_is_empty(tablespaceoid, tablespacename);
-=======
-       /*
-        * Try to remove the physical infrastructure.
-        */
-       if (!destroy_tablespace_directories(tablespaceoid, false))
-       {
-               /*
-                * Not all files deleted?  However, there can be lingering 
empty files
-                * in the directories, left behind by for example DROP TABLE, 
that
-                * have been scheduled for deletion at next checkpoint (see 
comments
-                * in mdunlink() for details).  We could just delete them 
immediately,
-                * but we can't tell them apart from important data files that 
we
-                * mustn't delete.  So instead, we force a checkpoint which 
will clean
-                * out any lingering files, and try again.
-                */
-               RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | 
CHECKPOINT_WAIT);
-
-               /*
-                * On Windows, an unlinked file persists in the directory 
listing
-                * until no process retains an open handle for the file.  The 
DDL
-                * commands that schedule files for unlink send invalidation 
messages
-                * directing other PostgreSQL processes to close the files, but
-                * nothing guarantees they'll be processed in time.  So, we'll 
also
-                * use a global barrier to ask all backends to close all files, 
and
-                * wait until they're finished.
-                */
-               LWLockRelease(TablespaceCreateLock);
-               
WaitForProcSignalBarrier(EmitProcSignalBarrier(PROCSIGNAL_BARRIER_SMGRRELEASE));
-               LWLockAcquire(TablespaceCreateLock, LW_EXCLUSIVE);
-
-               /* And now try again. */
-               if (!destroy_tablespace_directories(tablespaceoid, false))
-               {
-                       /* Still not empty, the files must be important then */
-                       ereport(ERROR,
-                                       
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-                                        errmsg("tablespace \"%s\" is not 
empty",
-                                                       tablespacename)));
-               }
-       }
->>>>>>> REL_16_9
 
        /* Record the filesystem change in XLOG */
        {
@@ -873,7 +807,6 @@ DropTableSpace(DropTableSpaceStmt *stmt)
 
        /* We keep the lock on pg_tablespace until commit */
        table_close(rel, NoLock);
-<<<<<<< HEAD
 
        /*
         * If we are the QD, dispatch this DROP command to all the QEs
@@ -888,13 +821,6 @@ DropTableSpace(DropTableSpaceStmt *stmt)
                                                                        NULL);
        }
 
-#else                                                  /* !HAVE_SYMLINK */
-       ereport(ERROR,
-                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                        errmsg("tablespaces are not supported on this 
platform")));
-#endif                                                 /* HAVE_SYMLINK */
-=======
->>>>>>> REL_16_9
 }
 
 /*
@@ -916,31 +842,9 @@ create_tablespace_directories(const char *location, const 
Oid tablespaceoid)
                tablespaceoid, GpIdentity.dbid);
 
        linkloc = psprintf("pg_tblspc/%u", tablespaceoid);
-<<<<<<< HEAD
        location_with_dbid_dir = psprintf("%s/%d", location, GpIdentity.dbid);
        location_with_version_dir = psprintf("%s/%s", location_with_dbid_dir,
                                                                                
 GP_TABLESPACE_VERSION_DIRECTORY);
-=======
-
-       /*
-        * If we're asked to make an 'in place' tablespace, create the directory
-        * directly where the symlink would normally go.  This is a 
developer-only
-        * option for now, to facilitate regression testing.
-        */
-       in_place = strlen(location) == 0;
-
-       if (in_place)
-       {
-               if (MakePGDirectory(linkloc) < 0 && errno != EEXIST)
-                       ereport(ERROR,
-                                       (errcode_for_file_access(),
-                                        errmsg("could not create directory 
\"%s\": %m",
-                                                       linkloc)));
-       }
-
-       location_with_version_dir = psprintf("%s/%s", in_place ? linkloc : 
location,
-                                                                               
 TABLESPACE_VERSION_DIRECTORY);
->>>>>>> REL_16_9
 
        /*
         * Attempt to coerce target directory to safe permissions.  If this 
fails,
@@ -964,22 +868,6 @@ create_tablespace_directories(const char *location, const 
Oid tablespaceoid)
        }
 
        /*
-<<<<<<< HEAD
-        * In GPDB each segment has a directory with its unique dbid under the
-        * tablespace path. Unlike the location_with_version_dir, do not error 
out
-        * if it already exists.
-        */
-       if (stat(location_with_dbid_dir, &st) < 0) 
-       {
-               if (errno == ENOENT)
-               {
-                       if (mkdir(location_with_dbid_dir, S_IRWXU) < 0)
-                                       ereport(ERROR,
-                                                       
(errcode_for_file_access(),
-                                                               errmsg("could 
not create directory \"%s\": %m", location_with_dbid_dir)));
-               }
-               else
-=======
         * The creation of the version directory prevents more than one 
tablespace
         * in a single location.  This imitates TablespaceCreateDbspace(), but 
it
         * ignores concurrency and missing parent directories.  The chmod() 
would
@@ -994,40 +882,11 @@ create_tablespace_directories(const char *location, const 
Oid tablespaceoid)
                                         errmsg("could not stat directory 
\"%s\": %m",
                                                        
location_with_version_dir)));
                else if (MakePGDirectory(location_with_version_dir) < 0)
->>>>>>> REL_16_9
                        ereport(ERROR,
                                        (errcode_for_file_access(),
                                                errmsg("could not stat 
directory \"%s\": %m", location_with_dbid_dir)));
 
        }
-<<<<<<< HEAD
-       else
-               ereport(DEBUG1,
-                               (errmsg("directory \"%s\" already exists in 
tablespace",
-                                       location_with_dbid_dir)));
-
-       /*
-        * The creation of the version directory prevents more than one 
tablespace
-        * in a single location.  This imitates TablespaceCreateDbspace(), but 
it
-        * ignores concurrency and missing parent directories.  The chmod() 
would
-        * have failed in the absence of a parent.  pg_tablespace_spcname_index
-        * prevents concurrency.
-        */
-       if (stat(location_with_version_dir, &st) < 0)
-       {
-               if (errno != ENOENT)
-                       ereport(ERROR,
-                                       (errcode_for_file_access(),
-                                        errmsg("could not stat directory 
\"%s\": %m",
-                                                       
location_with_version_dir)));
-               else if (MakePGDirectory(location_with_version_dir) < 0)
-                       ereport(ERROR,
-                                       (errcode_for_file_access(),
-                                 errmsg("could not create directory \"%s\": 
%m",
-                                                location_with_version_dir)));
-       }
-=======
->>>>>>> REL_16_9
        else if (!S_ISDIR(st.st_mode))
                ereport(ERROR,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -1048,11 +907,7 @@ create_tablespace_directories(const char *location, const 
Oid tablespaceoid)
        /*
         * Create the symlink under PGDATA
         */
-<<<<<<< HEAD
        if (symlink(location_with_dbid_dir, linkloc) < 0)
-=======
-       if (!in_place && symlink(location, linkloc) < 0)
->>>>>>> REL_16_9
                ereport(ERROR,
                                (errcode_for_file_access(),
                                 errmsg("could not create symbolic link \"%s\": 
%m",
@@ -2174,14 +2029,9 @@ tblspc_redo(XLogReaderState *record)
        }
        else if (info == XLOG_TBLSPC_DROP)
        {
-<<<<<<< HEAD
-=======
-               xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) 
XLogRecGetData(record);
-
                /* Close all smgr fds in all backends. */
                
WaitForProcSignalBarrier(EmitProcSignalBarrier(PROCSIGNAL_BARRIER_SMGRRELEASE));
 
->>>>>>> REL_16_9
                /*
                 * We no longer remove tablespace directories while replaying
                 * XLOG_TBLSPC_DROP. We wait until the commit for the 
tablespace drop
diff --git a/src/backend/commands/tsearchcmds.c 
b/src/backend/commands/tsearchcmds.c
index 6e1343099f7..4684493721d 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -49,17 +49,15 @@
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
-<<<<<<< HEAD
 #include "cdb/cdbvars.h"
 #include "cdb/cdbdisp_query.h"
-=======
+
 /* Single entry of List returned by getTokenTypes() */
 typedef struct
 {
        int                     num;                    /* token type number */
        char       *name;                       /* token type name */
 } TSTokenTypeItem;
->>>>>>> REL_16_9
 
 static void MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
                                                                         
HeapTuple tup, Relation relMap);
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 0e46b6c2d68..cd251b4a724 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -3,13 +3,9 @@
  * user.c
  *       Commands for manipulating roles (formerly called users).
  *
-<<<<<<< HEAD
  * Portions Copyright (c) 2005-2010, 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
  *
  * src/backend/commands/user.c
@@ -46,11 +42,8 @@
 #include "storage/lmgr.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
-<<<<<<< HEAD
-#include "utils/date.h"
-=======
 #include "utils/catcache.h"
->>>>>>> REL_16_9
+#include "utils/date.h"
 #include "utils/fmgroids.h"
 #include "utils/syscache.h"
 #include "utils/timestamp.h"
@@ -91,7 +84,6 @@ typedef enum
 #include "libpq/auth.h"
 #include "utils/resource_manager.h"
 
-<<<<<<< HEAD
 #include "cdb/cdbdisp_query.h"
 #include "cdb/cdbvars.h"
 
@@ -101,7 +93,7 @@ typedef struct extAuthPair
        char       *protocol;
        char       *type;
 } extAuthPair;
-=======
+
 typedef struct
 {
        unsigned        specified;
@@ -109,7 +101,6 @@ typedef struct
        bool            inherit;
        bool            set;
 } GrantRoleOptions;
->>>>>>> REL_16_9
 
 #define GRANT_ROLE_SPECIFIED_ADMIN                     0x0001
 #define GRANT_ROLE_SPECIFIED_INHERIT           0x0002
@@ -129,8 +120,8 @@ static void AddRoleMems(Oid currentUserId, const char 
*rolename, Oid roleid,
                                                Oid grantorId, GrantRoleOptions 
*popt);
 static void DelRoleMems(Oid currentUserId, const char *rolename, Oid roleid,
                                                List *memberSpecs, List 
*memberIds,
-<<<<<<< HEAD
-                                               bool admin_opt);
+                                               Oid grantorId, GrantRoleOptions 
*popt,
+                                               DropBehavior behavior);
 static extAuthPair *TransformExttabAuthClause(DefElem *defel);
 static void SetCreateExtTableForRole(List* allow,
                        List* disallow, bool* createrextgpfd,
@@ -145,9 +136,7 @@ static void AddRoleDenials(const char *rolename, Oid roleid,
                        List *addintervals);
 static void DelRoleDenials(const char *rolename, Oid roleid,
                        List *dropintervals);
-=======
-                                               Oid grantorId, GrantRoleOptions 
*popt,
-                                               DropBehavior behavior);
+
 static void check_role_membership_authorization(Oid currentUserId, Oid roleid,
                                                                                
                bool is_grant);
 static Oid     check_role_grantor(Oid currentUserId, Oid roleid, Oid grantorId,
@@ -166,7 +155,6 @@ static void plan_recursive_revoke(CatCList *memlist,
                                                                  bool 
revoke_admin_option_only,
                                                                  DropBehavior 
behavior);
 static void InitGrantRoleOptions(GrantRoleOptions *popt);
->>>>>>> REL_16_9
 
 
 /* Check if current user has createrole privileges */
@@ -236,15 +224,12 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
        DefElem    *dadminmembers = NULL;
        DefElem    *dvalidUntil = NULL;
        DefElem    *dbypassRLS = NULL;
-<<<<<<< HEAD
+       GrantRoleOptions popt;
        DefElem    *dprofile = NULL;
        DefElem    *daccountIsLock = NULL;
        DefElem    *denableProfile = NULL;
 
        now = GetCurrentTimestamp();
-=======
-       GrantRoleOptions popt;
->>>>>>> REL_16_9
 
        /* The defaults can vary depending on the original statement type */
        switch (stmt->stmt_type)
@@ -455,7 +440,6 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
        if (dresgroup)
                resgroup = strVal(linitial((List *) dresgroup->arg));
        if (dbypassRLS)
-<<<<<<< HEAD
                bypassrls = intVal(dbypassRLS->arg) != 0;
        if (dprofile)
                profilename = strVal(dprofile->arg);
@@ -464,6 +448,9 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
        if (denableProfile)
                enable_profile = intVal(denableProfile->arg) != 0;
 
+
+       bypassrls = boolVal(dbypassRLS->arg);
+
        /*
         * Only the super user has the privileges of profile.
         */
@@ -506,10 +493,6 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
                                         errmsg("must be superuser to create 
role enable/disable profile")));
        }
 
-=======
-               bypassrls = boolVal(dbypassRLS->arg);
->>>>>>> REL_16_9
-
        /* Check some permissions first */
        if (!superuser_arg(currentUserId))
        {
@@ -1036,33 +1019,18 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        ListCell   *option;
        char       *rolename;
        char       *password = NULL;    /* user password */
-<<<<<<< HEAD
        char       *profilename = NULL; /* profile name the role be attached */
-       int                     issuper = -1;   /* Make the user a superuser? */
-       int                     inherit = -1;   /* Auto inherit privileges? */
-       int                     createrole = -1;        /* Can this user create 
roles? */
-       int                     createdb = -1;  /* Can the user create 
databases? */
-       int                     canlogin = -1;  /* Can this user login? */
-       int                     isreplication = -1; /* Is this a replication 
role? */
-       int                     connlimit = -1; /* maximum connections allowed 
*/
        bool                    enable_profile = false; /* whether user can use 
password profile */
        char       *resqueue = NULL;    /* resource queue for this role */
        char       *resgroup = NULL;    /* resource group for this role */
        List       *exttabcreate = NIL; /* external table create privileges 
being added  */
        List       *exttabnocreate = NIL;       /* external table create 
privileges being removed */
-       List       *rolemembers = NIL;  /* roles to be added/removed */
-       char       *validUntil = NULL;  /* time the login is valid until */
-       Datum           validUntil_datum;       /* same, as timestamptz Datum */
-       bool            validUntil_null;
-       int                     bypassrls = -1;
        int                     account_is_lock = -1;   /* whether the account 
will be locked/unlocked */
        TimestampTz             now = 0;                /* current timestamp 
with time zone */
-=======
        int                     connlimit = -1; /* maximum connections allowed 
*/
        char       *validUntil = NULL;  /* time the login is valid until */
        Datum           validUntil_datum;       /* same, as timestamptz Datum */
        bool            validUntil_null;
->>>>>>> REL_16_9
        DefElem    *dpassword = NULL;
        DefElem    *dresqueue = NULL;
        DefElem    *dresgroup = NULL;
@@ -1080,7 +1048,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        DefElem    *daccountIsLock = NULL;
        DefElem    *denableProfile = NULL;
        Oid                     roleid;
-<<<<<<< HEAD
        bool            bWas_super = false;     /* Was the user a superuser? */
        int                     numopts = 0;
        char       *alter_subtype = ""; /* metadata tracking: kind of
@@ -1092,6 +1059,9 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        List       *dropintervals = NIL;        /* list of time intervals for 
which matching rules should be dropped */
        Oid                     queueid;
 
+       Oid                     currentUserId = GetUserId();
+       GrantRoleOptions popt;
+
        numopts = list_length(stmt->options);
 
        if (numopts > 1)
@@ -1106,10 +1076,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        {
                alter_subtype = "0 OPTIONS";
        }
-=======
-       Oid                     currentUserId = GetUserId();
-       GrantRoleOptions popt;
->>>>>>> REL_16_9
 
        check_rolespec_name(stmt->role,
                                                _("Cannot alter reserved 
roles."));
@@ -1294,13 +1260,10 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        }
        if (dvalidUntil)
                validUntil = strVal(dvalidUntil->arg);
-<<<<<<< HEAD
        if (dresqueue)
                resqueue = strVal(linitial((List *) dresqueue->arg));
        if (dresgroup)
                resgroup = strVal(linitial((List *) dresgroup->arg));
-       if (dbypassRLS)
-               bypassrls = intVal(dbypassRLS->arg);
        if (dprofile)
                profilename = strVal(dprofile->arg);
        if (daccountIsLock)
@@ -1349,8 +1312,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
                                        
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                         errmsg("must be superuser to alter 
role enable/disable profile")));
        }
-=======
->>>>>>> REL_16_9
 
        /*
         * Scan the pg_authid relation to be certain the user exists.
@@ -1381,15 +1342,11 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
         * Most changes to a role require that you both have CREATEROLE 
privileges
         * and also ADMIN OPTION on the role.
         */
-<<<<<<< HEAD
 
        bWas_super = ((Form_pg_authid) GETSTRUCT(tuple))->rolsuper;
 
-       if (authform->rolsuper || issuper >= 0)
-=======
        if (!have_createrole_privilege() ||
                !is_admin_of_role(GetUserId(), roleid))
->>>>>>> REL_16_9
        {
                /* things an unprivileged user certainly can't do */
                if (dinherit || dcreaterole || dcreatedb || dcanlogin || 
dconnlimit ||
@@ -1424,29 +1381,10 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
                if (disreplication && !has_rolreplication(currentUserId))
                        ereport(ERROR,
                                        
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-<<<<<<< HEAD
-                                        errmsg("must be superuser to change 
bypassrls attribute")));
-       }
-       else if (!have_createrole_privilege())
-       {
-               /* We already checked issuper, isreplication, and bypassrls */
-               if (!(inherit < 0 &&
-                         createrole < 0 &&
-                         createdb < 0 &&
-                         canlogin < 0 &&
-                         !dconnlimit &&
-                         !rolemembers &&
-                         !validUntil &&
-                         dpassword &&
-                         !exttabcreate &&
-                         !exttabnocreate &&
-                         roleid == GetUserId()))
-=======
                                         errmsg("permission denied to alter 
role"),
                                         errdetail("Only roles with the %s 
attribute may change the %s attribute.",
                                                           "REPLICATION", 
"REPLICATION")));
                if (dbypassRLS && !has_bypassrls_privilege(currentUserId))
->>>>>>> REL_16_9
                        ereport(ERROR,
                                        
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                         errmsg("permission denied to alter 
role"),
@@ -1498,12 +1436,8 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
         */
        if (dissuper)
        {
-<<<<<<< HEAD
                bool isNull;
                Oid roleResgroup;
-
-               new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(issuper 
> 0);
-=======
                bool            should_be_super = boolVal(dissuper->arg);
 
                if (!should_be_super && roleid == BOOTSTRAP_SUPERUSERID)
@@ -1514,7 +1448,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
                                                           "SUPERUSER")));
 
                new_record[Anum_pg_authid_rolsuper - 1] = 
BoolGetDatum(should_be_super);
->>>>>>> REL_16_9
                new_record_repl[Anum_pg_authid_rolsuper - 1] = true;
 
                roleResgroup = heap_getattr(tuple, Anum_pg_authid_rolresgroup,
@@ -1795,7 +1728,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        new_record_nulls[Anum_pg_authid_rolvaliduntil - 1] = validUntil_null;
        new_record_repl[Anum_pg_authid_rolvaliduntil - 1] = true;
 
-<<<<<<< HEAD
        /* profile name */
        if (profilename)
        {
@@ -1939,10 +1871,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
                }
        }
 
-       if (bypassrls >= 0)
-=======
        if (dbypassRLS)
->>>>>>> REL_16_9
        {
                new_record[Anum_pg_authid_rolbypassrls - 1] = 
BoolGetDatum(boolVal(dbypassRLS->arg));
                new_record_repl[Anum_pg_authid_rolbypassrls - 1] = true;
@@ -1957,7 +1886,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
        ReleaseSysCache(tuple);
        heap_freetuple(new_tuple);
 
-<<<<<<< HEAD
        if (stmt->tags)
        {
                if (!stmt->unsettag)
@@ -1978,9 +1906,8 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
                                                                 rolename);
                }
        }
-=======
+
        InitGrantRoleOptions(&popt);
->>>>>>> REL_16_9
 
        /*
         * Advance command counter so we can see new record; else tests in
@@ -1992,24 +1919,23 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
 
                CommandCounterIncrement();
 
-<<<<<<< HEAD
        if (stmt->action == +1)         /* add members to role */
        {
                if (rolemembers)
                        alter_subtype = "ADD USER";
 
-               AddRoleMems(rolename, roleid,
+               AddRoleMems(currentUserId, rolename, roleid,
                                        rolemembers, 
roleSpecsToIds(rolemembers),
-                                       GetUserId(), false);
+                                       InvalidOid, &popt);
        }
        else if (stmt->action == -1)    /* drop members from role */
        {
                if (rolemembers)
                        alter_subtype = "DROP USER";
 
-               DelRoleMems(rolename, roleid,
+               DelRoleMems(currentUserId, rolename, roleid,
                                        rolemembers, 
roleSpecsToIds(rolemembers),
-                                       false);
+                                       InvalidOid, &popt, DROP_RESTRICT);
        }
 
        if (bWas_super)
@@ -2059,17 +1985,6 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
                                                   roleid,
                                                   GetUserId(),
                                                   "ALTER", alter_subtype);
-=======
-               if (stmt->action == +1) /* add members to role */
-                       AddRoleMems(currentUserId, rolename, roleid,
-                                               rolemembers, 
roleSpecsToIds(rolemembers),
-                                               InvalidOid, &popt);
-               else if (stmt->action == -1)    /* drop members from role */
-                       DelRoleMems(currentUserId, rolename, roleid,
-                                               rolemembers, 
roleSpecsToIds(rolemembers),
-                                               InvalidOid, &popt, 
DROP_RESTRICT);
-       }
->>>>>>> REL_16_9
 
        /*
         * Close pg_authid, but keep lock till commit.
@@ -2347,7 +2262,6 @@ DropRole(DropRoleStmt *stmt)
                systable_endscan(sscan);
 
                /*
-<<<<<<< HEAD
                 * Remove all role history passwords from pg_password_history.
                 */
                ScanKeyInit(&scankey,
@@ -2375,11 +2289,6 @@ DropRole(DropRoleStmt *stmt)
                 */
                DelRoleDenials(role, roleid, NIL);
 
-               /*
-                * Remove any comments or security labels on this role.
-                */
-               DeleteSharedComments(roleid, AuthIdRelationId);
-               DeleteSharedSecurityLabel(roleid, AuthIdRelationId);
                
                /*
                 * Delete any tag description and associated dependencies.
@@ -2392,14 +2301,6 @@ DropRole(DropRoleStmt *stmt)
                if (Gp_role == GP_ROLE_DISPATCH)
                        MetaTrackDropObject(AuthIdRelationId,
                                                                roleid);
-               /*
-                * Remove settings for this role.
-                */
-               DropSetting(InvalidOid, roleid);
-
-               /*
-=======
->>>>>>> REL_16_9
                 * Advance command counter so that later iterations of this 
loop will
                 * see the changes already made.  This is essential if, for 
example,
                 * we are trying to drop both a role and one of its direct 
members ---
@@ -2738,8 +2639,7 @@ GrantRole(ParseState *pstate, GrantRoleStmt *stmt)
                else
                        DelRoleMems(currentUserId, rolename, roleid,
                                                stmt->grantee_roles, 
grantee_ids,
-<<<<<<< HEAD
-                                               stmt->admin_opt);
+                                               grantor, &popt, stmt->behavior);
 
                /* MPP-6929: metadata tracking */
                if (Gp_role == GP_ROLE_DISPATCH)
@@ -2749,10 +2649,6 @@ GrantRole(ParseState *pstate, GrantRoleStmt *stmt)
                                                                   "PRIVILEGE",
                                                                   
(stmt->is_grant) ? "GRANT" : "REVOKE"
                                                );
-
-=======
-                                               grantor, &popt, stmt->behavior);
->>>>>>> REL_16_9
        }
 
        /*
@@ -2904,63 +2800,8 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid 
roleid,
 
        Assert(list_length(memberSpecs) == list_length(memberIds));
 
-<<<<<<< HEAD
-       /* Skip permission check if nothing to do */
-       if (!memberIds)
-               return;
-
-       /*
-        * Check permissions: must have createrole or admin option on the role 
to
-        * be changed.  To mess with a superuser role, you gotta be superuser.
-        */
-       if (superuser_arg(roleid))
-       {
-               if (!superuser())
-                       ereport(ERROR,
-                                       
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                                        errmsg("must be superuser to alter 
superusers")));
-       }
-       else
-       {
-               if (!have_createrole_privilege() &&
-                       !is_admin_of_role(grantorId, roleid))
-                       ereport(ERROR,
-                                       
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                                        errmsg("must have admin option on role 
\"%s\"",
-                                                       rolename)));
-       }
-
-       /*
-        * The charter of pg_database_owner is to have exactly one, implicit,
-        * situation-dependent member.  There's no technical need for this
-        * restriction.  (One could lift it and take the further step of making
-        * pg_database_ownercheck() equivalent to has_privs_of_role(roleid,
-        * ROLE_PG_DATABASE_OWNER), in which case explicit, 
situation-independent
-        * members could act as the owner of any database.)
-        */
-       if (roleid == ROLE_PG_DATABASE_OWNER)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INVALID_GRANT_OPERATION),
-                                errmsg("role \"%s\" cannot have explicit 
members", rolename)));
-
-       /*
-        * The role membership grantor of record has little significance at
-        * present.  Nonetheless, inasmuch as users might look to it for a crude
-        * audit trail, let only superusers impute the grant to a third party.
-        *
-        * Before lifting this restriction, give the member == role case of
-        * is_admin_of_role() a fresh look.  Ensure that the current role cannot
-        * use an explicit grantor specification to take advantage of the 
session
-        * user's self-admin right.
-        */
-       if (grantorId != GetUserId() && !superuser())
-               ereport(ERROR,
-                               (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                                errmsg("must be superuser to set grantor")));
-=======
        /* Validate grantor (and resolve implicit grantor if not specified). */
        grantorId = check_role_grantor(currentUserId, roleid, grantorId, true);
->>>>>>> REL_16_9
 
        pg_authmem_rel = table_open(AuthMemRelationId, RowExclusiveLock);
        pg_authmem_dsc = RelationGetDescr(pg_authmem_rel);
@@ -3049,14 +2890,6 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid 
roleid,
                actions = initialize_revoke_actions(memlist);
                foreach(iditem, memberIds)
                {
-<<<<<<< HEAD
-                       if (Gp_role != GP_ROLE_EXECUTE)
-                       ereport(NOTICE,
-                                       (errmsg("role \"%s\" is already a 
member of role \"%s\"",
-                                                       
get_rolespec_name(memberRole), rolename)));
-                       ReleaseSysCache(authmem_tuple);
-                       continue;
-=======
                        Oid                     memberid = lfirst_oid(iditem);
 
                        if (memberid == BOOTSTRAP_SUPERUSERID)
@@ -3065,7 +2898,6 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid 
roleid,
                                                 errmsg("%s option cannot be 
granted back to your own grantor",
                                                                "ADMIN")));
                        plan_member_revoke(memlist, actions, memberid);
->>>>>>> REL_16_9
                }
 
                /*
@@ -3673,7 +3505,6 @@ DelRoleMems(Oid currentUserId, const char *rolename, Oid 
roleid,
 }
 
 /*
-<<<<<<< HEAD
  * ExtractAuthIntervalClause
  *
  * Build an authInterval struct (defined above) from given input
@@ -3808,13 +3639,13 @@ AddRoleDenials(const char *rolename, Oid roleid, List 
*addintervals)
 static void
 DelRoleDenials(const char *rolename, Oid roleid, List *dropintervals)
 {
-       Relation    pg_auth_time_rel;
+       Relation pg_auth_time_rel;
        ScanKeyData scankey;
        SysScanDesc sscan;
-       ListCell        *intervalitem;
-       bool            dropped_matching_interval = false;
+       ListCell *intervalitem;
+       bool dropped_matching_interval = false;
 
-       HeapTuple       tmp_tuple;
+       HeapTuple tmp_tuple;
 
        pg_auth_time_rel = table_open(AuthTimeConstraintRelationId, 
RowExclusiveLock);
 
@@ -3829,15 +3660,17 @@ DelRoleDenials(const char *rolename, Oid roleid, List 
*dropintervals)
        {
                if (dropintervals != NIL)
                {
-                       Form_pg_auth_time_constraint obj = 
(Form_pg_auth_time_constraint) GETSTRUCT(tmp_tuple);
-                       authInterval *interval, *existing = (authInterval *) 
palloc0(sizeof(authInterval));
+                       Form_pg_auth_time_constraint obj = 
(Form_pg_auth_time_constraint) GETSTRUCT(
+                                       tmp_tuple);
+                       authInterval *interval, *existing = (authInterval *) 
palloc0(
+                                       sizeof(authInterval));
                        existing->start.day = obj->start_day;
                        existing->start.time = obj->start_time;
                        existing->end.day = obj->end_day;
                        existing->end.time = obj->end_time;
                        foreach(intervalitem, dropintervals)
                        {
-                               interval = (authInterval *)lfirst(intervalitem);
+                               interval = (authInterval *) 
lfirst(intervalitem);
                                if (interval_overlap(existing, interval))
                                {
                                        if (Gp_role == GP_ROLE_DISPATCH)
@@ -3845,9 +3678,13 @@ DelRoleDenials(const char *rolename, Oid roleid, List 
*dropintervals)
                                                                
(errmsg("dropping DENY rule for \"%s\" between %s %s and %s %s",
                                                                                
rolename,
                                                                                
daysofweek[existing->start.day],
-                                                                               
DatumGetCString(DirectFunctionCall1(time_out, 
TimeADTGetDatum(existing->start.time))),
+                                                                               
DatumGetCString(DirectFunctionCall1(time_out,
+                                                                               
                                                                        
TimeADTGetDatum(
+                                                                               
                                                                                
        existing->start.time))),
                                                                                
daysofweek[existing->end.day],
-                                                                               
DatumGetCString(DirectFunctionCall1(time_out, 
TimeADTGetDatum(existing->end.time))))));
+                                                                               
DatumGetCString(DirectFunctionCall1(time_out,
+                                                                               
                                                                        
TimeADTGetDatum(
+                                                                               
                                                                                
        existing->end.time))))));
                                        CatalogTupleDelete(pg_auth_time_rel, 
&tmp_tuple->t_self);
                                        dropped_matching_interval = true;
                                        break;
@@ -3862,7 +3699,7 @@ DelRoleDenials(const char *rolename, Oid roleid, List 
*dropintervals)
        if (dropintervals && !dropped_matching_interval)
                ereport(ERROR,
                                (errcode(ERRCODE_UNDEFINED_OBJECT),
-                                errmsg("cannot find matching DENY rules for 
\"%s\"", rolename)));
+                                               errmsg("cannot find matching 
DENY rules for \"%s\"", rolename)));
 
        systable_endscan(sscan);
 
@@ -3871,7 +3708,9 @@ DelRoleDenials(const char *rolename, Oid roleid, List 
*dropintervals)
         * prevent any risk of deadlock failure while updating flat file)
         */
        table_close(pg_auth_time_rel, NoLock);
-=======
+}
+
+/*
  * Check that currentUserId has permission to modify the membership list for
  * roleid. Throw an error if not.
  */
@@ -4347,5 +4186,4 @@ assign_createrole_self_grant(const char *newval, void 
*extra)
                (options & GRANT_ROLE_SPECIFIED_INHERIT) != 0;
        createrole_self_grant_options.set =
                (options & GRANT_ROLE_SPECIFIED_SET) != 0;
->>>>>>> REL_16_9
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to