Skip to content

Commit

Permalink
*: use exprstatic.ExprContext to replace mock.Context in `ToConst…
Browse files Browse the repository at this point in the history
…raint` (#56355)

ref #53388
  • Loading branch information
lcwangchao authored Sep 27, 2024
1 parent 9435af1 commit b32b63c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/table/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"//pkg/errno",
"//pkg/expression",
"//pkg/expression/exprctx",
"//pkg/expression/exprstatic",
"//pkg/kv",
"//pkg/meta/autoid",
"//pkg/meta/model",
Expand All @@ -34,7 +35,6 @@ go_library(
"//pkg/util/hack",
"//pkg/util/intest",
"//pkg/util/logutil",
"//pkg/util/mock",
"//pkg/util/sqlexec",
"//pkg/util/timeutil",
"//pkg/util/tracing",
Expand Down
7 changes: 3 additions & 4 deletions pkg/table/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package table
import (
"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/expression/exprstatic"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/parser/ast"
pmodel "github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/util/dbterror"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mock"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -69,9 +69,8 @@ func removeInvalidCheckConstraintsInfo(tblInfo *model.TableInfo) {

// ToConstraint converts model.ConstraintInfo to Constraint
func ToConstraint(constraintInfo *model.ConstraintInfo, tblInfo *model.TableInfo) (*Constraint, error) {
ctx := mock.NewContext()
dbName := ctx.GetSessionVars().CurrentDB
expr, err := buildConstraintExpression(ctx, constraintInfo.ExprString, dbName, tblInfo)
ctx := exprstatic.NewExprContext()
expr, err := buildConstraintExpression(ctx, constraintInfo.ExprString, "", tblInfo)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit b32b63c

Please sign in to comment.