Skip to content

Commit

Permalink
add checker.ctx from 48596
Browse files Browse the repository at this point in the history
  • Loading branch information
time-and-fate committed Feb 19, 2024
1 parent 2342e32 commit a0e7da6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/util/ranger/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import (
"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/collate"
)

// conditionChecker checks if this condition can be pushed to index planner.
type conditionChecker struct {
ctx sessionctx.Context
checkerCol *expression.Column
length int
optPrefixIndexSingleScan bool
Expand Down
5 changes: 5 additions & 0 deletions pkg/util/ranger/detacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ func (d *rangeDetacher) detachCNFCondAndBuildRangeForIndex(conditions []expressi
return res, nil
}
checker := &conditionChecker{
ctx: d.sctx,
checkerCol: d.cols[eqOrInCount],
length: d.lengths[eqOrInCount],
optPrefixIndexSingleScan: d.sctx.GetSessionVars().OptPrefixIndexSingleScan,
Expand Down Expand Up @@ -710,6 +711,7 @@ func ExtractEqAndInCondition(sctx sessionctx.Context, conditions []expression.Ex
// We will detach the conditions of every DNF items, then compose them to a DNF.
func (d *rangeDetacher) detachDNFCondAndBuildRangeForIndex(condition *expression.ScalarFunction, newTpSlice []*types.FieldType) (Ranges, []expression.Expression, []*valueInfo, bool, error) {
firstColumnChecker := &conditionChecker{
ctx: d.sctx,
checkerCol: d.cols[0],
length: d.lengths[0],
optPrefixIndexSingleScan: d.sctx.GetSessionVars().OptPrefixIndexSingleScan,
Expand Down Expand Up @@ -978,6 +980,7 @@ func AppendConditionsIfNotExist(conditions, condsToAppend []expression.Expressio
// we don't need to return the remained filter conditions, it is much simpler than DetachCondsForColumn.
func ExtractAccessConditionsForColumn(ctx sessionctx.Context, conds []expression.Expression, col *expression.Column) []expression.Expression {
checker := conditionChecker{
ctx: ctx,
checkerCol: col,
length: types.UnspecifiedLength,
optPrefixIndexSingleScan: ctx.GetSessionVars().OptPrefixIndexSingleScan,
Expand All @@ -993,6 +996,7 @@ func ExtractAccessConditionsForColumn(ctx sessionctx.Context, conds []expression
// DetachCondsForColumn detaches access conditions for specified column from other filter conditions.
func DetachCondsForColumn(sctx sessionctx.Context, conds []expression.Expression, col *expression.Column) (accessConditions, otherConditions []expression.Expression) {
checker := &conditionChecker{
ctx: sctx,
checkerCol: col,
length: types.UnspecifiedLength,
optPrefixIndexSingleScan: sctx.GetSessionVars().OptPrefixIndexSingleScan,
Expand All @@ -1016,6 +1020,7 @@ func MergeDNFItems4Col(ctx sessionctx.Context, dnfItems []expression.Expression)

uniqueID := cols[0].UniqueID
checker := &conditionChecker{
ctx: ctx,
checkerCol: cols[0],
length: types.UnspecifiedLength,
optPrefixIndexSingleScan: ctx.GetSessionVars().OptPrefixIndexSingleScan,
Expand Down

0 comments on commit a0e7da6

Please sign in to comment.