From fed03127ba4144993ba682b7d56fd8f32045d093 Mon Sep 17 00:00:00 2001 From: wangliang Date: Mon, 24 Jul 2023 14:50:21 +0800 Subject: [PATCH 1/2] add hashdata extension storage_am related hook, All the QE will return its storage_am feature related meta data by control data tunnel, we add hook when the QD processing the data returned from control data tunnel. and also rewrite the check condiation for update scenario to make a wholerow attribute for not only the appendonly table but all the tables except heap table including our new hashdata involved table format. --- src/backend/executor/execUtils.c | 5 +++++ src/backend/executor/nodeModifyTable.c | 4 ++-- src/backend/optimizer/util/appendinfo.c | 2 +- src/include/cdb/cdbdispatchresult.h | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index b5d9cba778a..11b5f629e0b 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -99,6 +99,7 @@ static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc); static void ShutdownExprContext(ExprContext *econtext, bool isCommit); static List *flatten_logic_exprs(Node *node); +ProcessDispatchResult_hook_type ProcessDispatchResult_hook = NULL; /* ---------------------------------------------------------------- @@ -2052,6 +2053,10 @@ void mppExecutorFinishup(QueryDesc *queryDesc) ReThrowError(qeError); } + if (ProcessDispatchResult_hook) { + ProcessDispatchResult_hook(ds); + } + /* collect pgstat from QEs for current transaction level */ pgstat_combine_from_qe(pr, primaryWriterSliceIndex); diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index b2489121d32..f8e25170def 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -2662,7 +2662,7 @@ ExecModifyTable(PlanState *pstate) * making the update plan is consistent whether it generated by pg optimizer * or ORCA optimizer in the future. */ - if (operation == CMD_UPDATE && RelationIsAppendOptimized(resultRelInfo->ri_RelationDesc) && + if (operation == CMD_UPDATE && !RelationIsHeap(resultRelInfo->ri_RelationDesc) && AttributeNumberIsValid(resultRelInfo->ri_WholeRowNo)) { /* ri_WholeRowNo refers to a wholerow attribute */ @@ -3132,7 +3132,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) elog(ERROR, "could not find junk ctid column"); /* extra GPDB junk columns for update AO table */ - if (operation == CMD_UPDATE && RelationIsAppendOptimized(resultRelInfo->ri_RelationDesc)) + if (operation == CMD_UPDATE && !RelationIsHeap(resultRelInfo->ri_RelationDesc)) { resultRelInfo->ri_WholeRowNo = ExecFindJunkAttributeInTlist(subplan->targetlist, "wholerow"); diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c index 49c76411d30..e786c4499fd 100644 --- a/src/backend/optimizer/util/appendinfo.c +++ b/src/backend/optimizer/util/appendinfo.c @@ -951,7 +951,7 @@ add_row_identity_columns(PlannerInfo *root, Index rtindex, * format or making the update plan is consistent whether it generated by pg optimizer * or ORCA optimizer. */ - if (commandType == CMD_UPDATE && RelationIsAppendOptimized(target_relation)) + if (commandType == CMD_UPDATE && !RelationIsHeap(target_relation)) { var = makeVar(rtindex, InvalidAttrNumber, diff --git a/src/include/cdb/cdbdispatchresult.h b/src/include/cdb/cdbdispatchresult.h index 47bbfce8aa7..a5cc1862946 100644 --- a/src/include/cdb/cdbdispatchresult.h +++ b/src/include/cdb/cdbdispatchresult.h @@ -316,5 +316,7 @@ cdbdisp_makeDispatchResults(struct CdbDispatcherState *ds, void cdbdisp_clearCdbPgResults(CdbPgResults* cdb_pgresults); +typedef void (*ProcessDispatchResult_hook_type) (CdbDispatcherState*); +extern PGDLLIMPORT ProcessDispatchResult_hook_type ProcessDispatchResult_hook; #endif /* CDBDISPATCHRESULT_H */ From 256a04f56e43b18e5d91a23c773ac9145dd749e0 Mon Sep 17 00:00:00 2001 From: wangliang Date: Thu, 10 Aug 2023 16:58:46 +0800 Subject: [PATCH 2/2] fix alignment --- src/backend/executor/execUtils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 11b5f629e0b..80684fc7791 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -2053,9 +2053,8 @@ void mppExecutorFinishup(QueryDesc *queryDesc) ReThrowError(qeError); } - if (ProcessDispatchResult_hook) { - ProcessDispatchResult_hook(ds); - } + if (ProcessDispatchResult_hook) + ProcessDispatchResult_hook(ds); /* collect pgstat from QEs for current transaction level */ pgstat_combine_from_qe(pr, primaryWriterSliceIndex);