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 29648d94306 Fix compile errors for commands
29648d94306 is described below

commit 29648d9430609dbf72373d73aafe277860abc50a
Author: Jinbao Chen <[email protected]>
AuthorDate: Fri Oct 3 17:20:44 2025 +0800

    Fix compile errors for commands
---
 src/backend/commands/analyze.c       |  13 +-
 src/backend/commands/async.c         |  15 +-
 src/backend/commands/cluster.c       |   8 +-
 src/backend/commands/collationcmds.c |   6 +-
 src/backend/commands/copy.c          |   3 +-
 src/backend/commands/copyfrom.c      |  12 +-
 src/backend/commands/copyfromparse.c |   8 +-
 src/backend/commands/copyto.c        | 318 +----------------------------------
 src/backend/commands/createas.c      |   7 +-
 src/backend/commands/dbcommands.c    |  14 +-
 src/include/optimizer/optimizer.h    |   2 +-
 src/include/utils/sampling.h         |  17 --
 12 files changed, 39 insertions(+), 384 deletions(-)

diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index eb2f367c8e2..ddf9d4d3f34 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -187,17 +187,10 @@ static VacAttrStats *examine_attribute(Relation onerel, 
int attnum,
 static int acquire_sample_rows_dispatcher(Relation onerel, bool inh, int 
elevel,
                                                                                
  HeapTuple *rows, int targrows,
                                                                                
  double *totalrows, double *totaldeadrows);
-static int     acquire_sample_rows(Relation onerel, int elevel,
-                                                               HeapTuple 
*rows, int targrows,
-                                                               double 
*totalrows, double *totaldeadrows);
 static int     compare_rows(const void *a, const void *b, void *arg);
-static int     acquire_inherited_sample_rows(Relation onerel, int elevel,
-                                                                               
  HeapTuple *rows, int targrows,
-                                                                               
  double *totalrows, double *totaldeadrows);
 static BlockNumber acquire_index_number_of_blocks(Relation indexrel, Relation 
tablerel);
 
 static void gp_acquire_correlations_dispatcher(Oid relOid, bool inh, float4 
*correlations, bool *correlationsIsNull);
-static int     compare_rows(const void *a, const void *b);
 static void update_attstats(Oid relid, bool inh,
                                                        int natts, VacAttrStats 
**vacattrstats);
 static Datum std_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull);
@@ -845,7 +838,6 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
                HeapTuple *validRows = (HeapTuple *) palloc(numrows * 
sizeof(HeapTuple));
                MemoryContext col_context,
                                        old_context;
-               bool            build_ext_stats;
 
                pgstat_progress_update_param(PROGRESS_ANALYZE_PHASE,
                                                                         
PROGRESS_ANALYZE_PHASE_COMPUTE_STATS);
@@ -943,7 +935,6 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
                                 */
                                if (onerel->rd_rel->relkind == RELKIND_RELATION 
&& onerel->rd_rel->relispartition)
                                {
-                                       MemoryContext old_context;
                                        Datum *hll_values;
 
                                        old_context = 
MemoryContextSwitchTo(stats->anl_context);
@@ -2308,7 +2299,7 @@ acquire_hll_by_query(Relation onerel, int nattrs, 
VacAttrStats **attrstats, int
                        bool typbyval;
                        get_typlenbyval(SPI_tuptable->tupdesc->tdtypeid, 
&typlen, &typbyval);
                        int hll_length = datumGetSize(vals[tupattnum-1], 
typbyval, typlen);
-                       attrstats[j]->stahll_full = (bytea 
*)datumCopy(PointerGetDatum(vals[tupattnum - 1]), false, hll_length);
+                       attrstats[j]->stahll_full = (bytea 
*)datumCopy(vals[tupattnum - 1], false, hll_length);
                }
        }
 
@@ -2647,7 +2638,7 @@ static QueryDesc *build_querydesc(Portal portal, char 
*sql)
        Assert(list_length(raw_parsetree_list) == 1);
        parsetree = (RawStmt *) linitial(raw_parsetree_list);
 
-       querytree_list = pg_analyze_and_rewrite(parsetree,
+       querytree_list = pg_analyze_and_rewrite_fixedparams(parsetree,
                                                                                
        sql,
                                                                                
        NULL,
                                                                                
        0,
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 767d171d03a..e3a6921f0cd 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1236,20 +1236,6 @@ Exec_UnlistenAllCommit(void)
        listenChannels = NIL;
 }
 
-/*
- * ProcessCompletedNotifies --- nowadays this does nothing
- *
- * This routine used to send signals and handle self-notifies,
- * but that functionality has been moved elsewhere.
- * We'd delete it entirely, except that the documentation used to instruct
- * background-worker authors to call it.  To avoid an ABI break in stable
- * branches, keep it as a no-op routine.
- */
-void
-ProcessCompletedNotifies(void)
-{
-}
-
 /*
  * Test whether we are actively listening on the given channel name.
  *
@@ -2253,6 +2239,7 @@ static void
 ProcessIncomingNotify(bool flush)
 {
        bool            client_wait_timeout_enabled;
+       MemoryContext oldcontext;
 
        /* We *must* reset the flag */
        notifyInterruptPending = false;
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 7a3f5d9940b..8de0a0fa880 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -90,7 +90,7 @@ typedef struct
 } RelToCluster;
 
 
-static void cluster_multiple_rels(List *rtcs, ClusterParams *params, RangeVar 
*relation);
+static void cluster_multiple_rels(ClusterStmt *stmt, List *rtcs, ClusterParams 
*params, RangeVar *relation);
 static void rebuild_relation(Relation OldHeap, Oid indexOid, bool verbose);
 static void copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
                                                        bool verbose, bool 
*pSwapToastByContent,
@@ -291,7 +291,7 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool 
isTopLevel)
        }
 
        /* Do the job. */
-       cluster_multiple_rels(rtcs, &params, stmt->relation);
+       cluster_multiple_rels(stmt, rtcs, &params, stmt->relation);
 
        /* Start a new transaction for the cleanup work. */
        StartTransactionCommand();
@@ -308,7 +308,7 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool 
isTopLevel)
  * return.
  */
 static void
-cluster_multiple_rels(List *rtcs, ClusterParams *params, RangeVar *relation)
+cluster_multiple_rels(ClusterStmt *stmt, List *rtcs, ClusterParams *params, 
RangeVar *relation)
 {
        ListCell   *lc;
 
@@ -345,7 +345,7 @@ cluster_multiple_rels(List *rtcs, ClusterParams *params, 
RangeVar *relation)
                }
                /* See comments above. */
                if (IS_QD_OR_SINGLENODE())
-                       SetRelativeMatviewAuxStatus(rvtc->tableOid,
+                       SetRelativeMatviewAuxStatus(rtc->tableOid,
                                                                                
MV_DATA_STATUS_UP_REORGANIZED,
                                                                                
MV_DATA_STATUS_TRANSFER_DIRECTION_ALL);
 
diff --git a/src/backend/commands/collationcmds.c 
b/src/backend/commands/collationcmds.c
index 19525961573..69fa630ee02 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -635,8 +635,8 @@ DispatchCollationCreate(char *alias, char *locale, Oid 
nspid, char* provider)
        Assert(Gp_role == GP_ROLE_DISPATCH);
 
        List *names = NIL;
-       Value *schemaname = makeString(get_namespace_name(nspid));
-       Value *relname = makeString(alias);
+       String *schemaname = makeString(get_namespace_name(nspid));
+       String *relname = makeString(alias);
 
        names = lappend(names, schemaname);
        names = lappend(names, relname);
@@ -1029,6 +1029,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
                        const char *name;
                        char       *langtag;
                        char       *icucomment;
+                       const char *collcollate;
                        char       *collname;
                        Oid                     collid;
 
@@ -1038,6 +1039,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
                                name = uloc_getAvailable(i);
 
                        langtag = icu_language_tag(name, ERROR);
+                       collcollate = U_ICU_VERSION_MAJOR_NUM >= 54 ? langtag : 
name;
 
                        /*
                         * Be paranoid about not allowing any non-ASCII strings 
into
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index aaf38e974d4..ae5cb324e16 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -180,6 +180,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
        if (stmt->relation)
        {
                ParseNamespaceItem *nsitem;
+               RangeTblEntry *rte;
                RTEPermissionInfo *perminfo;
                TupleDesc       tupDesc;
                List       *attnums;
@@ -200,7 +201,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
 
                nsitem = addRangeTableEntryForRelation(pstate, rel, lockmode,
                                                                                
           NULL, false, false);
-
+               rte = nsitem->p_rte;
                perminfo = nsitem->p_perminfo;
                perminfo->requiredPerms = (is_from ? ACL_INSERT : ACL_SELECT);
 
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index 30a1f6c3af6..851e891bd54 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -924,7 +924,7 @@ CopyFromDirectoryTable(CopyFromState cstate)
         * index-entry-making machinery.  (There used to be a huge amount of 
code
         * here that basically duplicated execUtils.c ...)
         */
-       ExecInitRangeTable(estate, cstate->range_table);
+       ExecInitRangeTable(estate, cstate->range_table, cstate->rteperminfos);
        resultRelInfo = target_resultRelInfo = makeNode(ResultRelInfo);
        ExecInitResultRelation(estate, resultRelInfo, 1);
 
@@ -1112,7 +1112,7 @@ CopyFromDirectoryTable(CopyFromState cstate)
                CommandId       mycid = GetCurrentCommandId(true);
                MemoryContext oldcontext = CurrentMemoryContext;
                bool            has_tuple = false;
-               bool            update_indexes;
+               TU_UpdateIndexes                update_indexes;
 
                econtext = GetPerTupleExprContext(estate);
 
@@ -1159,7 +1159,8 @@ CopyFromDirectoryTable(CopyFromState cstate)
                                                                                
                   false,
                                                                                
                   false,
                                                                                
                   NULL,
-                                                                               
                   NIL);
+                                                                               
                   NIL,
+                                                                               
                   false);
 
                        /* AFTER ROW INSERT Triggers */
                        ExecARInsertTriggers(estate, resultRelInfo, myslot,
@@ -1291,7 +1292,7 @@ CopyFromDirectoryTable(CopyFromState cstate)
        {
                List       *recheckIndexes = NIL;
                CommandId       mycid = GetCurrentCommandId(true);
-               bool            update_indexes;
+               TU_UpdateIndexes                update_indexes;
 
                formDirTableSlot(cstate,
                                                 dirTable->spcId,
@@ -1313,7 +1314,8 @@ CopyFromDirectoryTable(CopyFromState cstate)
                                                                                
           false,
                                                                                
           false,
                                                                                
           NULL,
-                                                                               
           NIL);
+                                                                               
           NIL,
+                                                                               
           false);
 
                /* AFTER ROW INSERT Triggers */
                ExecARInsertTriggers(estate, resultRelInfo, myslot,
diff --git a/src/backend/commands/copyfromparse.c 
b/src/backend/commands/copyfromparse.c
index 24e38ca6868..0383fde7fa8 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -792,9 +792,9 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields, 
int *nfields)
                        int                     fldnum;
 
                        if (cstate->opts.csv_mode)
-                               fldct = CopyReadAttributesCSV(cstate);
+                               fldct = CopyReadAttributesCSV(cstate, -1);
                        else
-                               fldct = CopyReadAttributesText(cstate);
+                               fldct = CopyReadAttributesText(cstate, -1);
 
                        if (fldct != list_length(cstate->attnumlist))
                                ereport(ERROR,
@@ -847,9 +847,9 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields, 
int *nfields)
 
        /* Parse the line into de-escaped field values */
        if (cstate->opts.csv_mode)
-               fldct = CopyReadAttributesCSV(cstate);
+               fldct = CopyReadAttributesCSV(cstate, -1);
        else
-               fldct = CopyReadAttributesText(cstate);
+               fldct = CopyReadAttributesText(cstate, -1);
 
        *fields = cstate->raw_fields;
        *nfields = fldct;
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index c29020ce365..292d464ab93 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -55,17 +55,6 @@
 #include "cdb/cdbdisp_query.h"
 #include "cdb/cdbvars.h"
 
-/*
- * Represents the different dest cases we need to worry about at
- * the bottom level
- */
-typedef enum CopyDest
-{
-       COPY_FILE,                                      /* to file (or a piped 
program) */
-       COPY_FRONTEND,                          /* to frontend */
-       COPY_CALLBACK                           /* to callback function */
-} CopyDest;
-
 #define EXEC_DATA_P 0
 
 extern CopyStmt *glob_copystmt;
@@ -76,10 +65,8 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
 
 /* non-export function prototypes */
 static void EndCopy(CopyToState cstate);
-static void ClosePipeToProgram(CopyToState cstate);
-static void CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot);
-static void CopyAttributeOutText(CopyToState cstate, const char *string);
-static void CopyAttributeOutCSV(CopyToState cstate, const char *string,
+static void CopyAttributeOutText(CopyToState cstate, char *string);
+static void CopyAttributeOutCSV(CopyToState cstate, char *string,
                                                                bool use_quote, 
bool single_attr);
 static uint64 CopyToDispatch(CopyToState cstate);
 static void CopyToDispatchFlush(CopyToState cstate);
@@ -2403,304 +2390,3 @@ BeginCopyToDirectoryTable(ParseState *pstate,
                if (ptr > start) \
                        CopySendData(cstate, start, ptr - start); \
        } while (0)
-
-static void
-CopyAttributeOutText(CopyToState cstate, const char *string)
-{
-       const char *ptr;
-       const char *start;
-       char            c;
-       char            delimc = cstate->opts.delim[0];
-
-       if (cstate->need_transcoding)
-               ptr = pg_server_to_any(string, strlen(string), 
cstate->file_encoding);
-       else
-               ptr = string;
-
-       /*
-        * We have to grovel through the string searching for control characters
-        * and instances of the delimiter character.  In most cases, though, 
these
-        * are infrequent.  To avoid overhead from calling CopySendData once per
-        * character, we dump out all characters between escaped characters in a
-        * single call.  The loop invariant is that the data from "start" to 
"ptr"
-        * can be sent literally, but hasn't yet been.
-        *
-        * We can skip pg_encoding_mblen() overhead when encoding is safe, 
because
-        * in valid backend encodings, extra bytes of a multibyte character 
never
-        * look like ASCII.  This loop is sufficiently performance-critical that
-        * it's worth making two copies of it to get the IS_HIGHBIT_SET() test 
out
-        * of the normal safe-encoding path.
-        */
-       if (cstate->encoding_embeds_ascii)
-       {
-               start = ptr;
-               while ((c = *ptr) != '\0')
-               {
-                       if ((unsigned char) c < (unsigned char) 0x20)
-                       {
-                               /*
-                                * \r and \n must be escaped, the others are 
traditional. We
-                                * prefer to dump these using the C-like 
notation, rather than
-                                * a backslash and the literal character, 
because it makes the
-                                * dump file a bit more proof against 
Microsoftish data
-                                * mangling.
-                                */
-                               switch (c)
-                               {
-                                       case '\b':
-                                               c = 'b';
-                                               break;
-                                       case '\f':
-                                               c = 'f';
-                                               break;
-                                       case '\n':
-                                               c = 'n';
-                                               break;
-                                       case '\r':
-                                               c = 'r';
-                                               break;
-                                       case '\t':
-                                               c = 't';
-                                               break;
-                                       case '\v':
-                                               c = 'v';
-                                               break;
-                                       default:
-                                               /* If it's the delimiter, must 
backslash it */
-                                               if (c == delimc)
-                                                       break;
-                                               /* All ASCII control chars are 
length 1 */
-                                               ptr++;
-                                               continue;       /* fall to end 
of loop */
-                               }
-                               /* if we get here, we need to convert the 
control char */
-                               DUMPSOFAR();
-                               CopySendChar(cstate, '\\');
-                               CopySendChar(cstate, c);
-                               start = ++ptr;  /* do not include char in next 
run */
-                       }
-                       else if (c == '\\' || c == delimc)
-                       {
-                               DUMPSOFAR();
-                               CopySendChar(cstate, '\\');
-                               start = ptr++;  /* we include char in next run 
*/
-                       }
-                       else if (IS_HIGHBIT_SET(c))
-                               ptr += pg_encoding_mblen(cstate->file_encoding, 
ptr);
-                       else
-                               ptr++;
-               }
-       }
-       else
-       {
-               start = ptr;
-               while ((c = *ptr) != '\0')
-               {
-                       if ((unsigned char) c < (unsigned char) 0x20)
-                       {
-                               /*
-                                * \r and \n must be escaped, the others are 
traditional. We
-                                * prefer to dump these using the C-like 
notation, rather than
-                                * a backslash and the literal character, 
because it makes the
-                                * dump file a bit more proof against 
Microsoftish data
-                                * mangling.
-                                */
-                               switch (c)
-                               {
-                                       case '\b':
-                                               c = 'b';
-                                               break;
-                                       case '\f':
-                                               c = 'f';
-                                               break;
-                                       case '\n':
-                                               c = 'n';
-                                               break;
-                                       case '\r':
-                                               c = 'r';
-                                               break;
-                                       case '\t':
-                                               c = 't';
-                                               break;
-                                       case '\v':
-                                               c = 'v';
-                                               break;
-                                       default:
-                                               /* If it's the delimiter, must 
backslash it */
-                                               if (c == delimc)
-                                                       break;
-                                               /* All ASCII control chars are 
length 1 */
-                                               ptr++;
-                                               continue;       /* fall to end 
of loop */
-                               }
-                               /* if we get here, we need to convert the 
control char */
-                               DUMPSOFAR();
-                               CopySendChar(cstate, '\\');
-                               CopySendChar(cstate, c);
-                               start = ++ptr;  /* do not include char in next 
run */
-                       }
-                       else if (c == '\\' || c == delimc)
-                       {
-                               DUMPSOFAR();
-                               CopySendChar(cstate, '\\');
-                               start = ptr++;  /* we include char in next run 
*/
-                       }
-                       else
-                               ptr++;
-               }
-       }
-
-       DUMPSOFAR();
-}
-
-/*
- * Send text representation of one attribute, with conversion and
- * CSV-style escaping
- */
-static void
-CopyAttributeOutCSV(CopyToState cstate, const char *string,
-                                       bool use_quote, bool single_attr)
-{
-       const char *ptr;
-       const char *start;
-       char            c;
-       char            delimc = cstate->opts.delim[0];
-       char            quotec = cstate->opts.quote[0];
-       char            escapec = cstate->opts.escape[0];
-
-       /* force quoting if it matches null_print (before conversion!) */
-       if (!use_quote && strcmp(string, cstate->opts.null_print) == 0)
-               use_quote = true;
-
-       if (cstate->need_transcoding)
-               ptr = pg_server_to_any(string, strlen(string), 
cstate->file_encoding);
-       else
-               ptr = string;
-
-       /*
-        * Make a preliminary pass to discover if it needs quoting
-        */
-       if (!use_quote)
-       {
-               /*
-                * Because '\.' can be a data value, quote it if it appears 
alone on a
-                * line so it is not interpreted as the end-of-data marker.
-                */
-               if (single_attr && strcmp(ptr, "\\.") == 0)
-                       use_quote = true;
-               else
-               {
-                       const char *tptr = ptr;
-
-                       while ((c = *tptr) != '\0')
-                       {
-                               if (c == delimc || c == quotec || c == '\n' || 
c == '\r')
-                               {
-                                       use_quote = true;
-                                       break;
-                               }
-                               if (IS_HIGHBIT_SET(c) && 
cstate->encoding_embeds_ascii)
-                                       tptr += 
pg_encoding_mblen(cstate->file_encoding, tptr);
-                               else
-                                       tptr++;
-                       }
-               }
-       }
-
-       if (use_quote)
-       {
-               CopySendChar(cstate, quotec);
-
-               /*
-                * We adopt the same optimization strategy as in 
CopyAttributeOutText
-                */
-               start = ptr;
-               while ((c = *ptr) != '\0')
-               {
-                       if (c == quotec || c == escapec)
-                       {
-                               DUMPSOFAR();
-                               CopySendChar(cstate, escapec);
-                               start = ptr;    /* we include char in next run 
*/
-                       }
-                       if (IS_HIGHBIT_SET(c) && cstate->encoding_embeds_ascii)
-                               ptr += pg_encoding_mblen(cstate->file_encoding, 
ptr);
-                       else
-                               ptr++;
-               }
-               DUMPSOFAR();
-
-               CopySendChar(cstate, quotec);
-       }
-       else
-       {
-               /* If it doesn't need quoting, we can just dump it as-is */
-               CopySendString(cstate, ptr);
-       }
-}
-
-/*
- * copy_dest_startup --- executor startup
- */
-static void
-copy_dest_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
-{
-       /* no-op */
-}
-
-/*
- * copy_dest_receive --- receive one tuple
- */
-static bool
-copy_dest_receive(TupleTableSlot *slot, DestReceiver *self)
-{
-       DR_copy    *myState = (DR_copy *) self;
-       CopyToState cstate = myState->cstate;
-
-       /* Send the data */
-       CopyOneRowTo(cstate, slot);
-
-       /* Increment the number of processed tuples, and report the progress */
-       pgstat_progress_update_param(PROGRESS_COPY_TUPLES_PROCESSED,
-                                                                
++myState->processed);
-
-       return true;
-}
-
-/*
- * copy_dest_shutdown --- executor end
- */
-static void
-copy_dest_shutdown(DestReceiver *self)
-{
-       /* no-op */
-}
-
-/*
- * copy_dest_destroy --- release DestReceiver object
- */
-static void
-copy_dest_destroy(DestReceiver *self)
-{
-       pfree(self);
-}
-
-/*
- * CreateCopyDestReceiver -- create a suitable DestReceiver object
- */
-DestReceiver *
-CreateCopyDestReceiver(void)
-{
-       DR_copy    *self = (DR_copy *) palloc(sizeof(DR_copy));
-
-       self->pub.receiveSlot = copy_dest_receive;
-       self->pub.rStartup = copy_dest_startup;
-       self->pub.rShutdown = copy_dest_shutdown;
-       self->pub.rDestroy = copy_dest_destroy;
-       self->pub.mydest = DestCopyOut;
-
-       self->cstate = NULL;            /* will be set later */
-       self->processed = 0;
-
-       return (DestReceiver *) self;
-}
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index 129a152de87..e4ed2e71d23 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -1614,9 +1614,9 @@ CreateIndexOnIMMV(Query *query, Relation matviewRel)
        index->excludeOpNames = NIL;
        index->idxcomment = NULL;
        index->indexOid = InvalidOid;
-       index->oldNode = InvalidOid;
+       index->oldNumber = InvalidOid;
        index->oldCreateSubid = InvalidSubTransactionId;
-       index->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
+       index->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
        index->transformed = true;
        index->concurrent = false;
        index->if_not_exists = false;
@@ -1733,6 +1733,7 @@ CreateIndexOnIMMV(Query *query, Relation matviewRel)
                                                  InvalidOid,
                                                  InvalidOid,
                                                  InvalidOid,
+                                                 -1,
                                                  false, true, false, false, 
true);
 
        ereport(NOTICE,
@@ -1844,7 +1845,7 @@ get_primary_key_attnos_from_query(Query *query, List 
**constraintList)
        }
 
        /* Collect RTE indexes of relations appearing in the FROM clause */
-       rels_in_from = get_relids_in_jointree((Node *) query->jointree, false);
+       rels_in_from = get_relids_in_jointree((Node *) query->jointree, false, 
false);
 
        /*
         * Check if all key attributes of relations in FROM are appearing in 
the target
diff --git a/src/backend/commands/dbcommands.c 
b/src/backend/commands/dbcommands.c
index 5ccfeffa134..225d505ccba 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -156,7 +156,7 @@ static int  errdetail_busy_db(int notherbackends, int 
npreparedxacts);
 static void CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid, Oid 
src_tsid,
                                                                          Oid 
dst_tsid);
 static List *ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath);
-static List *ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid,
+static List *ScanSourceDatabasePgClassPage(Relation rel, Page page, Buffer 
buf, Oid tbid,
                                                                                
   Oid dbid, char *srcpath,
                                                                                
   List *rlocatorlist, Snapshot snapshot);
 static CreateDBRelInfo *ScanSourceDatabasePgClassTuple(HeapTupleData *tuple,
@@ -289,6 +289,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
        Snapshot        snapshot;
        SMgrRelation smgr;
        BufferAccessStrategy bstrategy;
+       Relation rel;
 
        /* Get pg_class relfilenumber. */
        relfilenumber = RelationMapOidToFilenumberForDatabase(srcpath,
@@ -304,7 +305,8 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
        rlocator.dbOid = dbid;
        rlocator.relNumber = relfilenumber;
 
-       smgr = smgropen(rlocator, InvalidBackendId);
+       rel = relation_open(RelationRelationId, AccessShareLock);
+       smgr = smgropen(rlocator, InvalidBackendId, SMGR_MD, rel);
        nblocks = smgrnblocks(smgr, MAIN_FORKNUM);
        smgrclose(smgr);
 
@@ -336,13 +338,14 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char 
*srcpath)
                }
 
                /* Append relevant pg_class tuples for current page to 
rlocatorlist. */
-               rlocatorlist = ScanSourceDatabasePgClassPage(page, buf, tbid, 
dbid,
+               rlocatorlist = ScanSourceDatabasePgClassPage(rel, page, buf, 
tbid, dbid,
                                                                                
                         srcpath, rlocatorlist,
                                                                                
                         snapshot);
 
                UnlockReleaseBuffer(buf);
        }
 
+       relation_close(rel, AccessShareLock);
        /* Release relation lock. */
        UnlockRelationId(&relid, AccessShareLock);
 
@@ -354,7 +357,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
  * entries to rlocatorlist. The return value is the updated list.
  */
 static List *
-ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
+ScanSourceDatabasePgClassPage(Relation rel, Page page, Buffer buf, Oid tbid, 
Oid dbid,
                                                          char *srcpath, List 
*rlocatorlist,
                                                          Snapshot snapshot)
 {
@@ -388,7 +391,7 @@ ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid 
tbid, Oid dbid,
                tuple.t_tableOid = RelationRelationId;
 
                /* Skip tuples that are not visible to this snapshot. */
-               if (HeapTupleSatisfiesVisibility(&tuple, snapshot, buf))
+               if (HeapTupleSatisfiesVisibility(rel, &tuple, snapshot, buf))
                {
                        CreateDBRelInfo *relinfo;
 
@@ -1678,7 +1681,6 @@ dropdb(const char *dbname, bool missing_ok, bool force)
 {
        Oid                     db_id = InvalidOid;
        bool            db_istemplate = true;
-       Oid                     defaultTablespace = InvalidOid;
        Relation        pgdbrel;
        HeapTuple       tup;
        ScanKeyData scankey;
diff --git a/src/include/optimizer/optimizer.h 
b/src/include/optimizer/optimizer.h
index e3473ccca7d..010d7ad7002 100644
--- a/src/include/optimizer/optimizer.h
+++ b/src/include/optimizer/optimizer.h
@@ -204,7 +204,7 @@ extern bool contain_vars_of_level(Node *node, int levelsup);
 extern bool contain_vars_of_level_or_above(Node *node, int levelsup);
 extern int     locate_var_of_level(Node *node, int levelsup);
 extern List *pull_var_clause(Node *node, int flags);
-extern Node *flatten_join_alias_vars(PlannerInfo *root, Query *query, Node 
*node);
+extern Node *flatten_join_alias_vars(Query *query, Node *node);
 
 extern bool contain_ctid_var_reference(Scan *scan);
 
diff --git a/src/include/utils/sampling.h b/src/include/utils/sampling.h
index d5f1a7f5d72..e26944887eb 100644
--- a/src/include/utils/sampling.h
+++ b/src/include/utils/sampling.h
@@ -41,23 +41,6 @@ extern BlockNumber BlockSampler_Init(BlockSampler bs, 
BlockNumber nblocks,
 extern bool BlockSampler_HasMore(BlockSampler bs);
 extern BlockNumber BlockSampler_Next(BlockSampler bs);
 
-/* 64 bit version of BlockSampler */
-typedef struct
-{
-       int64           N;                              /* number of objects, 
known in advance */
-       int64                   n;                              /* desired 
sample size */
-       int64           t;                              /* current object 
number */
-       int64                   m;                              /* objects 
selected so far */
-       SamplerRandomState randstate;   /* random generator state */
-} RowSamplerData;
-
-typedef RowSamplerData *RowSampler;
-
-extern void RowSampler_Init(RowSampler rs, int64 nobjects,
-                                                          int64 samplesize, 
long randseed);
-extern bool RowSampler_HasMore(RowSampler rs);
-extern int64 RowSampler_Next(RowSampler rs);
-
 /* Reservoir sampling methods */
 
 typedef struct


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

Reply via email to