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 3ff2d7bc157 Fix some compile errors in executor
3ff2d7bc157 is described below

commit 3ff2d7bc157b55e02fbaecf1c117a96fd1c62858
Author: Jinbao Chen <chenjinbao1...@gmail.com>
AuthorDate: Sun Sep 28 10:14:39 2025 +0800

    Fix some compile errors in executor
---
 src/backend/executor/execExpr.c          | 22 +++++-----
 src/backend/executor/execIndexing.c      |  9 +++-
 src/backend/executor/execMain.c          |  4 --
 src/backend/executor/execPartition.c     |  5 ++-
 src/backend/executor/execUtils.c         |  6 ---
 src/backend/executor/nodeAppend.c        |  7 ++++
 src/backend/executor/nodeHash.c          | 24 -----------
 src/backend/executor/nodeHashjoin.c      |  7 ++--
 src/backend/executor/nodeIndexonlyscan.c |  4 +-
 src/backend/executor/nodeMemoize.c       |  2 +-
 src/backend/utils/sort/logtape.c         | 71 --------------------------------
 src/include/catalog/pg_directory_table.h |  3 +-
 src/include/executor/nodeHash.h          |  1 +
 src/include/nodes/nodes.h                |  1 +
 src/include/portability/instr_time.h     |  5 +--
 src/include/postgres.h                   |  8 ++++
 src/include/utils/logtape.h              |  4 +-
 src/include/utils/resscheduler.h         |  2 +-
 18 files changed, 51 insertions(+), 134 deletions(-)

diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 3de64637906..de93d93958f 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -3727,7 +3727,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase 
phase,
        ExprState  *state = makeNode(ExprState);
        PlanState  *parent = &aggstate->ss.ps;
        ExprEvalStep scratch = {0};
-       LastAttnumInfo deform = {0, 0, 0};
+       ExprSetupInfo deform = {0, 0, 0, NIL};
 
        state->expr = (Expr *) aggstate;
        state->parent = parent;
@@ -3745,16 +3745,16 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase 
phase,
 
                if (!bms_is_member(transno, aggstate->aggs_used))
                        continue;
-               get_last_attnums_walker((Node *) 
pertrans->aggref->aggdirectargs,
-                                                               &deform);
-               get_last_attnums_walker((Node *) pertrans->aggref->args,
-                                                               &deform);
-               get_last_attnums_walker((Node *) pertrans->aggref->aggorder,
-                                                               &deform);
-               get_last_attnums_walker((Node *) pertrans->aggref->aggdistinct,
-                                                               &deform);
-               get_last_attnums_walker((Node *) pertrans->aggref->aggfilter,
-                                                               &deform);
+               expr_setup_walker((Node *) pertrans->aggref->aggdirectargs,
+                                                 &deform);
+               expr_setup_walker((Node *) pertrans->aggref->args,
+                                                 &deform);
+               expr_setup_walker((Node *) pertrans->aggref->aggorder,
+                                                 &deform);
+               expr_setup_walker((Node *) pertrans->aggref->aggdistinct,
+                                                 &deform);
+               expr_setup_walker((Node *) pertrans->aggref->aggfilter,
+                                                 &deform);
 
                if (aggstate->AggExprId_AttrNum > 0)
                        deform.last_outer = Max(deform.last_outer,
diff --git a/src/backend/executor/execIndexing.c 
b/src/backend/executor/execIndexing.c
index 156e8d2b8a9..689bb6f4825 100644
--- a/src/backend/executor/execIndexing.c
+++ b/src/backend/executor/execIndexing.c
@@ -136,6 +136,10 @@ static bool check_exclusion_or_unique_constraint(Relation 
heap, Relation index,
 static bool index_recheck_constraint(Relation index, Oid *constr_procs,
                                                                         Datum 
*existing_values, bool *existing_isnull,
                                                                         Datum 
*new_values);
+static bool index_unchanged_by_update(ResultRelInfo *resultRelInfo, EState 
*estate,
+                                                                         
IndexInfo *indexInfo, Relation indexRelation);
+static bool index_expression_changed_walker(Node *node,
+                                                                               
        Bitmapset *allUpdatedCols);
 
 /* ----------------------------------------------------------------
  *             ExecOpenIndices
@@ -431,7 +435,10 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
                 * This is a workaround for a bug in PostgreSQL 14.  In 
practice this
                 * won't make much difference for current users of the hint.
                 */
-               indexUnchanged = update;
+               indexUnchanged = update && 
index_unchanged_by_update(resultRelInfo,
+                                                                               
                                         estate,
+                                                                               
                                         indexInfo,
+                                                                               
                                         indexRelation);
 
                satisfiesConstraint =
                        index_insert(indexRelation, /* index relation */
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index c182a406cb3..945bfdc0beb 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1742,9 +1742,6 @@ ExecCheckXactReadOnly(PlannedStmt *plannedstmt)
                        continue;
 
                if (isTempNamespace(get_rel_namespace(perminfo->relid)))
-                       continue;
-
-               if (isTempNamespace(get_rel_namespace(rte->relid)))
                {
                        ExecutorMarkTransactionDoesWrites();
                        continue;
@@ -2842,7 +2839,6 @@ ExecutePlan(QueryDesc *queryDesc,
 {
        EState     *estate = queryDesc->estate;
        PlanState  *planstate = queryDesc->planstate;
-       bool            use_parallel_mode;
        TupleTableSlot *slot;
        uint64          current_tuple_count;
 
diff --git a/src/backend/executor/execPartition.c 
b/src/backend/executor/execPartition.c
index 01e1dbffd05..7bad41f294e 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -1899,7 +1899,8 @@ ExecInitPartitionPruning(PlanState *planstate,
         * Perform an initial partition prune pass, if required.
         */
        if (prunestate->do_initial_prune)
-               *initially_valid_subplans = 
ExecFindMatchingSubPlans(prunestate, true);
+               *initially_valid_subplans = 
ExecFindMatchingSubPlans(prunestate, true,
+                                                                               
                                         NULL, -1, NULL);
        else
        {
                /* No pruning, so we'll need to initialize all subplans */
@@ -2382,7 +2383,7 @@ ExecAddMatchingSubPlans(PartitionPruneState *prunestate, 
Bitmapset *result)
 {
        Bitmapset *thisresult;
 
-       thisresult = ExecFindMatchingSubPlans(prunestate, NULL, -1, NIL);
+       thisresult = ExecFindMatchingSubPlans(prunestate, true, NULL, -1, NIL);
 
        result = bms_add_members(result, thisresult);
 
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index f5631dfc938..f9d5719fbe3 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -2144,9 +2144,6 @@ void mppExecutorFinishup(QueryDesc *queryDesc)
                if (ProcessDispatchResult_hook)
                        ProcessDispatchResult_hook(ds);
 
-               /* collect pgstat from QEs for current transaction level */
-               pgstat_combine_from_qe(pr, primaryWriterSliceIndex);
-
                /* get num of rows processed from writer QEs. */
                estate->es_processed +=
                        cdbdisp_sumCmdTuples(pr, primaryWriterSliceIndex);
@@ -2222,9 +2219,6 @@ uint64 mppExecutorWait(QueryDesc *queryDesc)
                if (ProcessDispatchResult_hook)
                        ProcessDispatchResult_hook(ds);
 
-               /* collect pgstat from QEs for current transaction level */
-               pgstat_combine_from_qe(pr, primaryWriterSliceIndex);
-
                if (queryDesc->planstate->instrument && 
queryDesc->planstate->instrument->need_cdb)
                {
                        cdbexplain_recvExecStats(queryDesc->planstate, 
ds->primaryResults,
diff --git a/src/backend/executor/nodeAppend.c 
b/src/backend/executor/nodeAppend.c
index 54c8a4687b7..47f5773042f 100644
--- a/src/backend/executor/nodeAppend.c
+++ b/src/backend/executor/nodeAppend.c
@@ -563,6 +563,7 @@ choose_next_subplan_locally(AppendState *node)
 {
        int                     whichplan = node->as_whichplan;
        int                     nextplan;
+       Append     *plan = (Append *) node->ps.plan;
 
        /* We should never be called when there are no subplans */
        Assert(node->as_nplans > 0);
@@ -1114,6 +1115,12 @@ ExecAppendAsyncEventWait(AppendState *node)
                                                                                
 WAIT_EVENT_APPEND_READY);
                }
        }
+       PG_FINALLY();
+       {
+               FreeWaitEventSet(node->as_eventset);
+               node->as_eventset = NULL;
+       }
+       PG_END_TRY();
 
        /*
         * No need for further processing if there are no configured events 
other
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 22a8f0b3589..84af1afa47c 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -1042,7 +1042,6 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, 
bool useskew,
                 * more buckets if we have memory to spare */
                double          dbuckets_lower;
                double          dbuckets_upper;
-               double          dbuckets;
 
                /* divide our tuple row-count estimate by our the number of
                 * tuples we'd like in a bucket: this produces a small bucket
@@ -1415,7 +1414,6 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable 
hashtable)
                                        double          dtuples;
                                        double          dbuckets;
                                        int                     new_nbuckets;
-                                       uint32          max_buckets;
 
                                        /*
                                         * We probably also need a smaller 
bucket array.  How many
@@ -4315,28 +4313,6 @@ get_hash_memory_limit(void)
        return (size_t) mem_limit;
 }
 
-/*
- * Convert the hash memory limit to an integer number of kilobytes,
- * that is something comparable to work_mem.  Like work_mem, we clamp
- * the result to ensure that multiplying it by 1024 fits in a long int.
- *
- * This is deprecated since it may understate the actual memory limit.
- * It is unused in core and will eventually be removed.
- */
-size_t
-get_hash_memory_limit(void)
-{
-       double          mem_limit;
-
-       /* Do initial calculation in double arithmetic */
-       mem_limit = (double) work_mem * hash_mem_multiplier * 1024.0;
-
-       /* Clamp in case it doesn't fit in size_t */
-       mem_limit = Min(mem_limit, (double) SIZE_MAX);
-
-       return (size_t) mem_limit;
-}
-
 /*
  * Convert AttrFilter to ScanKeyData and send these runtime filters to the
  * target node(seqscan).
diff --git a/src/backend/executor/nodeHashjoin.c 
b/src/backend/executor/nodeHashjoin.c
index 6c97a4bd48e..acfd17a9923 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -1564,7 +1564,7 @@ ExecParallelHashJoinNewBatch(HashJoinState *hjstate)
 
                        if (hashtable->nbatch == 1 && batchno == 0 && 
((HashJoin *)hjstate->js.ps.plan)->batch0_barrier)
                        {
-                               Assert(phase == PHJ_BATCH_PROBING);
+                               Assert(phase == PHJ_BATCH_PROBE);
 
                                batch0_barrier = &pstate->batch0_barrier;
                                BarrierArriveAndWait(batch0_barrier, 
WAIT_EVENT_PARALLEL_FINISH);
@@ -2303,6 +2303,7 @@ CreateRuntimeFilter(HashJoinState* hjstate)
        HashState       *hstate;
        AttrFilter      *attr_filter;
        ListCell        *lc;
+       ListCell        *lc2;
        List            *targets;
 
        /*
@@ -2348,9 +2349,9 @@ CreateRuntimeFilter(HashJoinState* hjstate)
                if (lattno == -1 || targets == NULL)
                        continue;
 
-               foreach(lc, targets)
+               foreach(lc2, targets)
                {
-                       PlanState *target = lfirst(lc);
+                       PlanState *target = lfirst(lc2);
                        Assert(IsA(target, SeqScanState));
 
                        attr_filter = CreateAttrFilter(target, lattno, rattno,
diff --git a/src/backend/executor/nodeIndexonlyscan.c 
b/src/backend/executor/nodeIndexonlyscan.c
index da047413c0b..2dfffadb40f 100644
--- a/src/backend/executor/nodeIndexonlyscan.c
+++ b/src/backend/executor/nodeIndexonlyscan.c
@@ -540,6 +540,7 @@ ExecInitIndexOnlyScanForPartition(IndexOnlyScan *node, 
EState *estate, int eflag
 {
        IndexOnlyScanState *indexstate;
        LOCKMODE        lockmode;
+       Relation        indexRelation;
        TupleDesc       tupDesc;
        int                     indnkeyatts;
        int                     namecount;
@@ -610,7 +611,8 @@ ExecInitIndexOnlyScanForPartition(IndexOnlyScan *node, 
EState *estate, int eflag
 
        /* Open the index relation. */
        lockmode = exec_rt_fetch(node->scan.scanrelid, estate)->rellockmode;
-       indexstate->ioss_RelationDesc = index_open(indexid, lockmode);
+       indexRelation = index_open(indexid, lockmode);
+       indexstate->ioss_RelationDesc = indexRelation;
 
        /*
         * Initialize index-specific scan state
diff --git a/src/backend/executor/nodeMemoize.c 
b/src/backend/executor/nodeMemoize.c
index 27234ebaa11..ccf3df74225 100644
--- a/src/backend/executor/nodeMemoize.c
+++ b/src/backend/executor/nodeMemoize.c
@@ -248,7 +248,7 @@ MemoizeHash_equal(struct memoize_hash *tb, const MemoizeKey 
*key1,
                                                                attr->attbyval, 
attr->attlen))
                                return false;
                }
-               return true
+               return true;
        }
        else
        {
diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index 96a8dac350a..8bf97b4538b 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -737,77 +737,6 @@ ltsCreateTape(LogicalTapeSet *lts)
        return lt;
 }
 
-/*
- * Close a logical tape.
- *
- * Each tape is initialized in write state.  Serial callers pass ntapes,
- * NULL argument for shared, and -1 for worker.  Parallel worker callers
- * pass ntapes, a shared file handle, NULL shared argument,  and their own
- * worker number.  Leader callers, which claim shared worker tapes here,
- * must supply non-sentinel values for all arguments except worker number,
- * which should be -1.
- *
- * Leader caller is passing back an array of metadata each worker captured
- * when LogicalTapeFreeze() was called for their final result tapes.  Passed
- * tapes array is actually sized ntapes - 1, because it includes only
- * worker tapes, whereas leader requires its own leader tape.  Note that we
- * rely on the assumption that reclaimed worker tapes will only be read
- * from once by leader, and never written to again (tapes are initialized
- * for writing, but that's only to be consistent).  Leader may not write to
- * its own tape purely due to a restriction in the shared buffile
- * infrastructure that may be lifted in the future.
- */
-LogicalTapeSet *
-LogicalTapeSetCreate(int ntapes, bool preallocate, TapeShare *shared,
-                                        SharedFileSet *fileset, int worker)
-{
-       LogicalTapeSet *lts;
-       int                     i;
-
-       /*
-        * Create top-level struct including per-tape LogicalTape structs.
-        */
-       Assert(ntapes > 0);
-       lts = (LogicalTapeSet *) palloc(sizeof(LogicalTapeSet));
-       lts->nBlocksAllocated = 0L;
-       lts->nBlocksWritten = 0L;
-       lts->nHoleBlocks = 0L;
-       lts->forgetFreeSpace = false;
-       lts->freeBlocksLen = 32;        /* reasonable initial guess */
-       lts->freeBlocks = (long *) palloc(lts->freeBlocksLen * sizeof(long));
-       lts->nFreeBlocks = 0;
-       lts->enable_prealloc = preallocate;
-       lts->nTapes = ntapes;
-       lts->tapes = (LogicalTape *) palloc(ntapes * sizeof(LogicalTape));
-
-       for (i = 0; i < ntapes; i++)
-               ltsInitTape(&lts->tapes[i]);
-
-       /*
-        * Create temp BufFile storage as required.
-        *
-        * Leader concatenates worker tapes, which requires special adjustment 
to
-        * final tapeset data.  Things are simpler for the worker case and the
-        * serial case, though.  They are generally very similar -- workers use 
a
-        * shared fileset, whereas serial sorts use a conventional serial 
BufFile.
-        */
-       if (shared)
-               ltsConcatWorkerTapes(lts, shared, fileset);
-       else if (fileset)
-       {
-               char            filename[MAXPGPATH];
-               workfile_set *work_set;
-
-               pg_itoa(worker, filename);
-               work_set = workfile_mgr_create_set("LogicalTape", filename, 
false /* hold pin */);
-               lts->pfile = BufFileCreateShared(fileset, filename, work_set);
-       }
-       else
-               lts->pfile = BufFileCreateTemp("LogicalTape", false);
-
-       return lts;
-}
-
 /*
  * Close a logical tape set and release all resources.
  * Note: This doesn't return any blocks to the free list!  You must read
diff --git a/src/include/catalog/pg_directory_table.h 
b/src/include/catalog/pg_directory_table.h
index fb8c33d1711..4c1c3774b0c 100644
--- a/src/include/catalog/pg_directory_table.h
+++ b/src/include/catalog/pg_directory_table.h
@@ -49,8 +49,7 @@ typedef FormData_pg_directory_table *Form_pg_directory_table;
 
 DECLARE_TOAST(pg_directory_table, 8546, 8547);
 
-DECLARE_UNIQUE_INDEX_PKEY(pg_directory_table_relid_index, 8548, on 
pg_directory_table using btree(dtrelid oid_ops));
-#define DirectoryTableRelidIndexId     8548
+DECLARE_UNIQUE_INDEX_PKEY(pg_directory_table_relid_index, 8548, 
DirectoryTableRelidIndexId, on pg_directory_table using btree(dtrelid oid_ops));
 
 typedef struct DirectoryTable
 {
diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h
index 5f4f491a58b..d04941b27a3 100644
--- a/src/include/executor/nodeHash.h
+++ b/src/include/executor/nodeHash.h
@@ -91,6 +91,7 @@ extern void ExecHashAccumInstrumentation(HashInstrumentation 
*instrument,
 extern void ExecHashTableExplainInit(HashState *hashState, HashJoinState 
*hjstate,
                                      HashJoinTable  hashtable);
 extern void ExecHashTableExplainBatchEnd(HashState *hashState, HashJoinTable 
hashtable);
+extern void ExecHashTableReset(HashState *hashState, HashJoinTable hashtable);
 
 static inline int
 ExecHashRowSize(int tupwidth)
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index a61a77ea51a..5dbb522a1d0 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -616,6 +616,7 @@ typedef enum NodeTag
        T_Constraint,
        T_DefElem,
        T_RangeTblEntry,
+       T_RTEPermissionInfo,
        T_RangeTblFunction,
        T_TableSampleClause,
        T_WithCheckOption,
diff --git a/src/include/portability/instr_time.h 
b/src/include/portability/instr_time.h
index 4cae6a12e34..1f6e51ae75e 100644
--- a/src/include/portability/instr_time.h
+++ b/src/include/portability/instr_time.h
@@ -122,11 +122,8 @@ pg_clock_gettime_ns(void)
 #define INSTR_TIME_SET_CURRENT(t) \
        ((t) = pg_clock_gettime_ns())
 
-#ifdef CLOCK_MONOTONIC_COARSE
-#define INSTR_TIME_SET_CURRENT_COARSE(t)       ((void) 
clock_gettime(CLOCK_MONOTONIC_COARSE, &(t)))
-#else
 #define INSTR_TIME_SET_CURRENT_COARSE(t)       INSTR_TIME_SET_CURRENT(t)
-#endif
+
 
 #define INSTR_TIME_ASSIGN(x,y) ((x).tv_sec = (y).tv_sec, (x).tv_nsec = 
(y).tv_nsec)
 
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 2fcbceba7bd..06c13d296b5 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -538,6 +538,14 @@ Float8GetDatum(float8 X)
 extern Datum Float8GetDatum(float8 X);
 #endif
 
+
+static inline bool IsAligned(void *p, int align)
+{
+       int64 i = (int64) PointerGetDatum(p);
+       return ((i & (align-1)) == 0);
+}
+
+
 /* ----------------------------------------------------------------
  *                             Section 3:      exception handling backend 
support
  * ----------------------------------------------------------------
diff --git a/src/include/utils/logtape.h b/src/include/utils/logtape.h
index ebb448cb5e7..34fa2602f41 100644
--- a/src/include/utils/logtape.h
+++ b/src/include/utils/logtape.h
@@ -61,9 +61,7 @@ typedef struct TapeShare
 
 extern char * LogicalTapeGetBufFilename(const LogicalTapeSet *lts);
 
-extern LogicalTapeSet *LogicalTapeSetCreate(int ntapes, bool preallocate,
-                                                                               
        TapeShare *shared,
-                                                                               
        SharedFileSet *fileset, int worker);
+extern LogicalTapeSet *LogicalTapeSetCreate(bool preallocate, SharedFileSet 
*fileset, int worker);
 extern void LogicalTapeClose(LogicalTape *lt);
 extern void LogicalTapeSetClose(LogicalTapeSet *lts);
 extern LogicalTape *LogicalTapeCreate(LogicalTapeSet *lts);
diff --git a/src/include/utils/resscheduler.h b/src/include/utils/resscheduler.h
index aa815c7002c..e0194fc6bc8 100644
--- a/src/include/utils/resscheduler.h
+++ b/src/include/utils/resscheduler.h
@@ -94,7 +94,7 @@ typedef struct ResPortalIncrement
        uint32          portalId;                               /* Portal Id */
        bool            isHold;                                 /* Holdable 
cursor? */
        bool            isCommitted;                    /* 1st commit complete? 
*/
-       SHM_QUEUE       portalLink;                             /* List link in 
PROCLOCKS list 
+       dlist_head      portalLink;                             /* List link in 
PROCLOCKS list
                                                                                
   of ResPortalIncrements. */
        /* The increments - use Cost as it has a suitably large range. */
        Cost            increments[NUM_RES_LIMIT_TYPES];


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

Reply via email to