From 5527ff365b2139ff9876f06bace3559c12d1b529 Mon Sep 17 00:00:00 2001 From: Yang Keao Date: Thu, 29 Feb 2024 10:18:58 +0800 Subject: [PATCH] move BaseExecutorV2 outside Signed-off-by: Yang Keao --- pkg/executor/builder.go | 3 ++- pkg/executor/distsql.go | 3 ++- pkg/executor/index_merge_reader.go | 6 ++++-- pkg/executor/table_reader.go | 14 ++++++-------- pkg/executor/table_readers_required_rows_test.go | 3 ++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pkg/executor/builder.go b/pkg/executor/builder.go index 0c5ca1e778201..6edd4e9a8fa15 100644 --- a/pkg/executor/builder.go +++ b/pkg/executor/builder.go @@ -3209,7 +3209,8 @@ func buildNoRangeTableReader(b *executorBuilder, v *plannercore.PhysicalTableRea paging := b.ctx.GetSessionVars().EnablePaging e := &TableReaderExecutor{ - tableReaderExecutorContext: newTableReaderExecutorContext(b.ctx, v.Schema(), v.ID()), + BaseExecutorV2: exec.NewBaseExecutorV2(b.ctx.GetSessionVars(), v.Schema(), v.ID()), + tableReaderExecutorContext: newTableReaderExecutorContext(b.ctx), dagPB: dagReq, startTS: startTS, txnScope: b.txnScope, diff --git a/pkg/executor/distsql.go b/pkg/executor/distsql.go index 6b32d886c0ddd..078712f713d43 100644 --- a/pkg/executor/distsql.go +++ b/pkg/executor/distsql.go @@ -804,7 +804,8 @@ func (e *IndexLookUpExecutor) buildTableReader(ctx context.Context, task *lookup table = task.partitionTable } tableReaderExec := &TableReaderExecutor{ - tableReaderExecutorContext: newTableReaderExecutorContext(e.Ctx(), e.Schema(), e.getTableRootPlanID()), + BaseExecutorV2: exec.NewBaseExecutorV2(e.Ctx().GetSessionVars(), e.Schema(), e.getTableRootPlanID()), + tableReaderExecutorContext: newTableReaderExecutorContext(e.Ctx()), table: table, dagPB: e.tableRequest, startTS: e.startTS, diff --git a/pkg/executor/index_merge_reader.go b/pkg/executor/index_merge_reader.go index fbba8fc970557..e44682c5e184f 100644 --- a/pkg/executor/index_merge_reader.go +++ b/pkg/executor/index_merge_reader.go @@ -474,7 +474,8 @@ func (e *IndexMergeReaderExecutor) startPartialTableWorker(ctx context.Context, failpoint.Inject("testIndexMergePanicPartialTableWorker", nil) var err error partialTableReader := &TableReaderExecutor{ - tableReaderExecutorContext: newTableReaderExecutorContext(e.Ctx(), ts.Schema(), e.getPartitalPlanID(workID)), + BaseExecutorV2: exec.NewBaseExecutorV2(e.Ctx().GetSessionVars(), ts.Schema(), e.getPartitalPlanID(workID)), + tableReaderExecutorContext: newTableReaderExecutorContext(e.Ctx()), dagPB: e.dagPBs[workID], startTS: e.startTS, txnScope: e.txnScope, @@ -785,7 +786,8 @@ func (e *IndexMergeReaderExecutor) startIndexMergeTableScanWorker(ctx context.Co func (e *IndexMergeReaderExecutor) buildFinalTableReader(ctx context.Context, tbl table.Table, handles []kv.Handle) (_ exec.Executor, err error) { tableReaderExec := &TableReaderExecutor{ - tableReaderExecutorContext: newTableReaderExecutorContext(e.Ctx(), e.Schema(), e.getTablePlanRootID()), + BaseExecutorV2: exec.NewBaseExecutorV2(e.Ctx().GetSessionVars(), e.Schema(), e.getTablePlanRootID()), + tableReaderExecutorContext: newTableReaderExecutorContext(e.Ctx()), table: tbl, dagPB: e.tableRequest, startTS: e.startTS, diff --git a/pkg/executor/table_reader.go b/pkg/executor/table_reader.go index 4e4d72fd8b729..32fa2bc9c4840 100644 --- a/pkg/executor/table_reader.go +++ b/pkg/executor/table_reader.go @@ -77,8 +77,6 @@ type kvRangeBuilder interface { // tableReaderExecutorContext is the execution context for the `TableReaderExecutor` type tableReaderExecutorContext struct { - exec.BaseExecutorV2 - dctx distsqlctx.DistSQLContext pctx planctx.PlanContext ectx exprctx.BuildContext @@ -102,7 +100,7 @@ func (treCtx *tableReaderExecutorContext) GetDDLOwner(ctx context.Context) (*inf return nil, errors.New("GetDDLOwner in a context without DDL") } -func newTableReaderExecutorContext(sctx sessionctx.Context, schema *expression.Schema, id int) tableReaderExecutorContext { +func newTableReaderExecutorContext(sctx sessionctx.Context) tableReaderExecutorContext { // Explicitly get `ownerManager` out of the closure to show that the `tableReaderExecutorContext` itself doesn't // depend on `sctx` directly. // The context of some tests don't have `DDL`, so make it optional @@ -120,17 +118,17 @@ func newTableReaderExecutorContext(sctx sessionctx.Context, schema *expression.S } return tableReaderExecutorContext{ - BaseExecutorV2: exec.NewBaseExecutorV2(sctx.GetSessionVars(), schema, id), - dctx: sctx.GetDistSQLCtx(), - pctx: sctx.GetPlanCtx(), - ectx: sctx.GetExprCtx(), - getDDLOwner: getDDLOwner, + dctx: sctx.GetDistSQLCtx(), + pctx: sctx.GetPlanCtx(), + ectx: sctx.GetExprCtx(), + getDDLOwner: getDDLOwner, } } // TableReaderExecutor sends DAG request and reads table data from kv layer. type TableReaderExecutor struct { tableReaderExecutorContext + exec.BaseExecutorV2 table table.Table diff --git a/pkg/executor/table_readers_required_rows_test.go b/pkg/executor/table_readers_required_rows_test.go index e9538a5ad7139..238b5b3d31d20 100644 --- a/pkg/executor/table_readers_required_rows_test.go +++ b/pkg/executor/table_readers_required_rows_test.go @@ -131,7 +131,8 @@ func buildTableReader(sctx sessionctx.Context) exec.Executor { schema := expression.NewSchema(cols...) e := &TableReaderExecutor{ - tableReaderExecutorContext: newTableReaderExecutorContext(sctx, schema, 0), + BaseExecutorV2: exec.NewBaseExecutorV2(sctx.GetSessionVars(), schema, 0), + tableReaderExecutorContext: newTableReaderExecutorContext(sctx), table: &tables.TableCommon{}, dagPB: buildMockDAGRequest(sctx), selectResultHook: selectResultHook{mockSelectResult},