执行器优化,改为函数指针的方式,不访问全局数组

This commit is contained in:
wanghao19920907
2023-01-16 01:30:10 -08:00
parent eee21b1180
commit cbb5b4fe37
77 changed files with 378 additions and 515 deletions

View File

@ -147,6 +147,7 @@
#include "utils/memprot.h"
#include "workload/workload.h"
static TupleTableSlot* ExecAgg(PlanState* state);
static void initialize_aggregates(
AggState* aggstate, AggStatePerAgg peragg, AggStatePerGroup pergroup, int numReset = 0);
static void advance_transition_function(
@ -248,6 +249,8 @@ static TupleTableSlot* fetch_input_tuple(AggState* aggstate)
TupleTableSlot* slot = NULL;
if (aggstate->sort_in) {
/* make sure we check for interrupts in either path through here */
CHECK_FOR_INTERRUPTS();
if (!tuplesort_gettupleslot(aggstate->sort_in, true, aggstate->sort_slot, NULL))
return NULL;
slot = aggstate->sort_slot;
@ -1461,8 +1464,9 @@ static TupleTableSlot* agg_retrieve(AggState* node)
* stored in the expression context to be used when ExecProject evaluates
* the result tuple.
*/
TupleTableSlot* ExecAgg(AggState* node)
static TupleTableSlot* ExecAgg(PlanState* state)
{
AggState* node = castNode(AggState, state);
/*
* just for cooperation analysis. do nothing if is_dummy is true.
* is_dummy is true that means Agg node is deparsed to remote sql in ForeignScan node.
@ -1987,6 +1991,7 @@ AggState* ExecInitAgg(Agg* node, EState* estate, int eflags)
aggstate->sort_in = NULL;
aggstate->sort_out = NULL;
aggstate->is_final = node->is_final;
aggstate->ss.ps.ExecProcNode = ExecAgg;
/*
* Calculate the maximum number of grouping sets in any phase; this