Skip to content

Commit

Permalink
*: rename some packages of context (#56108)
Browse files Browse the repository at this point in the history
close #56107
  • Loading branch information
lcwangchao authored Sep 19, 2024
1 parent 70a26f8 commit 68fdf55
Show file tree
Hide file tree
Showing 157 changed files with 1,184 additions and 1,184 deletions.
8 changes: 4 additions & 4 deletions pkg/ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ go_library(
"//pkg/domain/infosync",
"//pkg/errctx",
"//pkg/expression",
"//pkg/expression/context",
"//pkg/expression/contextstatic",
"//pkg/expression/exprctx",
"//pkg/expression/exprstatic",
"//pkg/infoschema",
"//pkg/kv",
"//pkg/lightning/backend",
Expand Down Expand Up @@ -133,8 +133,8 @@ go_library(
"//pkg/store/driver/txn",
"//pkg/store/helper",
"//pkg/table",
"//pkg/table/context",
"//pkg/table/tables",
"//pkg/table/tblctx",
"//pkg/tablecodec",
"//pkg/tidb-binlog/pump_client",
"//pkg/ttl/cache",
Expand Down Expand Up @@ -293,7 +293,7 @@ go_test(
"//pkg/errno",
"//pkg/executor",
"//pkg/expression",
"//pkg/expression/contextstatic",
"//pkg/expression/exprstatic",
"//pkg/infoschema",
"//pkg/keyspace",
"//pkg/kv",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/add_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/pingcap/tidb/pkg/ddl/notifier"
"github.com/pingcap/tidb/pkg/errctx"
"github.com/pingcap/tidb/pkg/expression"
exprctx "github.com/pingcap/tidb/pkg/expression/context"
"github.com/pingcap/tidb/pkg/expression/exprctx"
"github.com/pingcap/tidb/pkg/infoschema"
"github.com/pingcap/tidb/pkg/meta"
"github.com/pingcap/tidb/pkg/meta/autoid"
Expand Down
8 changes: 4 additions & 4 deletions pkg/ddl/backfilling.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
ddlutil "github.com/pingcap/tidb/pkg/ddl/util"
"github.com/pingcap/tidb/pkg/disttask/operator"
"github.com/pingcap/tidb/pkg/expression"
exprctx "github.com/pingcap/tidb/pkg/expression/context"
"github.com/pingcap/tidb/pkg/expression/contextstatic"
"github.com/pingcap/tidb/pkg/expression/exprctx"
"github.com/pingcap/tidb/pkg/expression/exprstatic"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/metrics"
Expand Down Expand Up @@ -183,10 +183,10 @@ func newBackfillCtx(id int, rInfo *reorgInfo,
// See: https://github.com/pingcap/tidb/pull/25728 for more details.
hasStrictMode := rInfo.ReorgMeta.SQLMode.HasStrictMode()
tc := exprCtx.GetStaticEvalCtx().TypeCtx()
evalCtx := exprCtx.GetStaticEvalCtx().Apply(contextstatic.WithTypeFlags(
evalCtx := exprCtx.GetStaticEvalCtx().Apply(exprstatic.WithTypeFlags(
tc.Flags().WithIgnoreZeroDateErr(!hasStrictMode),
))
exprCtx = exprCtx.Apply(contextstatic.WithEvalCtx(evalCtx))
exprCtx = exprCtx.Apply(exprstatic.WithEvalCtx(evalCtx))
}

tblCtx := newReorgTableMutateContext(exprCtx)
Expand Down
40 changes: 20 additions & 20 deletions pkg/ddl/backfilling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/pingcap/tidb/pkg/ddl/ingest"
distsqlctx "github.com/pingcap/tidb/pkg/distsql/context"
"github.com/pingcap/tidb/pkg/errctx"
"github.com/pingcap/tidb/pkg/expression/contextstatic"
"github.com/pingcap/tidb/pkg/expression/exprstatic"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
Expand Down Expand Up @@ -96,21 +96,21 @@ func TestPickBackfillType(t *testing.T) {
require.Equal(t, tp, model.ReorgTypeLitMerge)
}

func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx *contextstatic.StaticExprContext, warnHandler contextutil.WarnHandler) {
func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx *exprstatic.ExprContext, warnHandler contextutil.WarnHandler) {
exprCtxManualCheckFields := []struct {
field string
check func(*contextstatic.StaticExprContext)
check func(*exprstatic.ExprContext)
}{
{
field: "evalCtx",
check: func(ctx *contextstatic.StaticExprContext) {
check: func(ctx *exprstatic.ExprContext) {
require.NotZero(t, ctx.GetEvalCtx().CtxID())
require.NotEqual(t, sctx.GetExprCtx().GetEvalCtx().CtxID(), ctx.GetEvalCtx().CtxID())
},
},
{
field: "blockEncryptionMode",
check: func(context *contextstatic.StaticExprContext) {
check: func(context *exprstatic.ExprContext) {
m := sctx.GetExprCtx().GetBlockEncryptionMode()
if m == "" {
// Empty string is not a valid encryption mode, so we expect the exprCtx.GetBlockEncryptionMode()
Expand All @@ -123,13 +123,13 @@ func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx
},
{
field: "rng",
check: func(ctx *contextstatic.StaticExprContext) {
check: func(ctx *exprstatic.ExprContext) {
require.NotNil(t, ctx.Rng())
},
},
{
field: "planCacheTracker",
check: func(ctx *contextstatic.StaticExprContext) {
check: func(ctx *exprstatic.ExprContext) {
require.Equal(t, sctx.GetExprCtx().IsUseCache(), ctx.IsUseCache())
ctx.SetSkipPlanCache("test reason")
require.False(t, ctx.IsUseCache())
Expand All @@ -139,24 +139,24 @@ func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx

evalCtxManualCheckFields := []struct {
field string
check func(*contextstatic.StaticEvalContext)
check func(*exprstatic.EvalContext)
}{
{
field: "warnHandler",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
require.Same(t, warnHandler, ctx.GetWarnHandler())
},
},
{
field: "typeCtx.warnHandler",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
ec := ctx.ErrCtx()
require.Equal(t, errctx.NewContextWithLevels(ec.LevelMap(), ctx), ec)
},
},
{
field: "typeCtx.loc",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
tc := ctx.TypeCtx()
require.Same(t, tc.Location(), ctx.Location())
require.Equal(t, sctx.GetSessionVars().Location().String(), tc.Location().String())
Expand All @@ -165,14 +165,14 @@ func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx
},
{
field: "errCtx.warnHandler",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
tc := ctx.TypeCtx()
require.Equal(t, types.NewContext(tc.Flags(), tc.Location(), ctx), tc)
},
},
{
field: "currentTime",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
tm1, err := sctx.GetExprCtx().GetEvalCtx().CurrentTime()
require.NoError(t, err)

Expand All @@ -184,7 +184,7 @@ func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx
},
{
field: "requestVerificationFn",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
// RequestVerification should allow all privileges
// that is the same with input session context (GetPrivilegeManager returns nil).
require.Nil(t, privilege.GetPrivilegeManager(sctx))
Expand All @@ -194,7 +194,7 @@ func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx
},
{
field: "requestDynamicVerificationFn",
check: func(ctx *contextstatic.StaticEvalContext) {
check: func(ctx *exprstatic.EvalContext) {
// RequestDynamicVerification should allow all privileges
// that is the same with input session context (GetPrivilegeManager returns nil).
require.Nil(t, privilege.GetPrivilegeManager(sctx))
Expand All @@ -204,21 +204,21 @@ func assertStaticExprContextEqual(t *testing.T, sctx sessionctx.Context, exprCtx
},
}

// check StaticExprContext except StaticEvalContext
// check ExprContext except EvalContext
expected := sctx.GetExprCtx().(*mock.Context).IntoStatic()
ignoreFields := make([]string, 0, len(exprCtxManualCheckFields))
for _, f := range exprCtxManualCheckFields {
f.check(exprCtx)
ignoreFields = append(ignoreFields, "$.staticExprCtxState."+f.field)
ignoreFields = append(ignoreFields, "$.exprCtxState."+f.field)
}
deeptest.AssertDeepClonedEqual(t, expected, exprCtx, deeptest.WithIgnorePath(ignoreFields))

// check StaticEvalContext
// check EvalContext
ignoreFields = make([]string, 0, len(evalCtxManualCheckFields))
ignoreFields = append(ignoreFields, "$.id")
for _, f := range evalCtxManualCheckFields {
f.check(exprCtx.GetStaticEvalCtx())
ignoreFields = append(ignoreFields, "$.staticEvalCtxState."+f.field)
ignoreFields = append(ignoreFields, "$.evalCtxState."+f.field)
}
deeptest.AssertDeepClonedEqual(
t,
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestReorgTableMutateContext(t *testing.T) {
originalRowFmt := variable.GetDDLReorgRowFormat()
defer variable.SetDDLReorgRowFormat(originalRowFmt)

exprCtx := contextstatic.NewStaticExprContext()
exprCtx := exprstatic.NewExprContext()

assertTblCtxMatchSessionCtx := func(ctx table.MutateContext, sctx sessionctx.Context) {
sctxTblCtx := sctx.GetTableCtx()
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddl/copr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_library(
deps = [
"//pkg/distsql/context",
"//pkg/expression",
"//pkg/expression/context",
"//pkg/expression/exprctx",
"//pkg/infoschema",
"//pkg/meta/model",
"//pkg/parser/model",
Expand All @@ -27,7 +27,7 @@ go_test(
shard_count = 3,
deps = [
"//pkg/expression",
"//pkg/expression/contextstatic",
"//pkg/expression/exprstatic",
"//pkg/meta/model",
"//pkg/parser/model",
"//pkg/parser/mysql",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/copr/copr_ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/errors"
distsqlctx "github.com/pingcap/tidb/pkg/distsql/context"
"github.com/pingcap/tidb/pkg/expression"
exprctx "github.com/pingcap/tidb/pkg/expression/context"
"github.com/pingcap/tidb/pkg/expression/exprctx"
// make sure mock.MockInfoschema is initialized to make sure the test pass
_ "github.com/pingcap/tidb/pkg/infoschema"
"github.com/pingcap/tidb/pkg/meta/model"
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddl/copr/copr_ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"

"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/expression/contextstatic"
"github.com/pingcap/tidb/pkg/expression/exprstatic"
"github.com/pingcap/tidb/pkg/meta/model"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestCollectVirtualColumnOffsetsAndTypes(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := contextstatic.NewStaticEvalContext()
ctx := exprstatic.NewEvalContext()
gotOffsets, gotFt := collectVirtualColumnOffsetsAndTypes(ctx, tt.cols)
require.Equal(t, gotOffsets, tt.offsets)
require.Equal(t, len(gotFt), len(tt.fieldTp))
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/index_cop.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
distsqlctx "github.com/pingcap/tidb/pkg/distsql/context"
"github.com/pingcap/tidb/pkg/errctx"
"github.com/pingcap/tidb/pkg/expression"
exprctx "github.com/pingcap/tidb/pkg/expression/context"
"github.com/pingcap/tidb/pkg/expression/exprctx"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/table"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/modify_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
sess "github.com/pingcap/tidb/pkg/ddl/session"
"github.com/pingcap/tidb/pkg/errctx"
"github.com/pingcap/tidb/pkg/expression"
exprctx "github.com/pingcap/tidb/pkg/expression/context"
"github.com/pingcap/tidb/pkg/expression/exprctx"
"github.com/pingcap/tidb/pkg/infoschema"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta"
Expand Down
Loading

0 comments on commit 68fdf55

Please sign in to comment.