Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types,*: remove the dependency stmtctx from types package. #48108

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ddl/column_modify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ AddLoop:
func(_ kv.Handle, data []types.Datum, cols []*table.Column) (bool, error) {
i++
// c4 must be -1 or > 0
v, err := data[3].ToInt64(tk.Session().GetSessionVars().StmtCtx)
v, err := data[3].ToInt64(tk.Session().GetSessionVars().StmtCtx.TypeCtx())
require.NoError(t, err)
if v == -1 {
j++
Expand Down
6 changes: 3 additions & 3 deletions pkg/ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ func getDefaultValue(ctx sessionctx.Context, col *table.Column, option *ast.Colu
val, err := getEnumDefaultValue(v, col)
return val, false, err
case mysql.TypeDuration, mysql.TypeDate:
if v, err = v.ConvertTo(ctx.GetSessionVars().StmtCtx, &col.FieldType); err != nil {
if v, err = v.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), &col.FieldType); err != nil {
return "", false, errors.Trace(err)
}
case mysql.TypeBit:
Expand All @@ -1380,7 +1380,7 @@ func getDefaultValue(ctx sessionctx.Context, col *table.Column, option *ast.Colu
// For these types, convert it to standard format firstly.
// like integer fields, convert it into integer string literals. like convert "1.25" into "1" and "2.8" into "3".
// if raise a error, we will use original expression. We will handle it in check phase
if temp, err := v.ConvertTo(ctx.GetSessionVars().StmtCtx, &col.FieldType); err == nil {
if temp, err := v.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), &col.FieldType); err == nil {
v = temp
}
}
Expand Down Expand Up @@ -7834,7 +7834,7 @@ func checkAndGetColumnsTypeAndValuesMatch(ctx sessionctx.Context, colTypes []typ
return nil, dbterror.ErrWrongTypeColumnValue.GenWithStackByArgs()
}
}
newVal, err := val.ConvertTo(ctx.GetSessionVars().StmtCtx, &colType)
newVal, err := val.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), &colType)
if err != nil {
return nil, dbterror.ErrWrongTypeColumnValue.GenWithStackByArgs()
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ func GeneratePartDefsFromInterval(ctx sessionctx.Context, tp ast.AlterTableType,
if err != nil {
return err
}
cmp, err := currVal.Compare(ctx.GetSessionVars().StmtCtx, &lastVal, collate.GetBinaryCollator())
cmp, err := currVal.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &lastVal, collate.GetBinaryCollator())
if err != nil {
return err
}
Expand Down Expand Up @@ -1427,7 +1427,7 @@ func checkPartitionValuesIsInt(ctx sessionctx.Context, defName interface{}, expr
return dbterror.ErrValuesIsNotIntType.GenWithStackByArgs(defName)
}

_, err = val.ConvertTo(ctx.GetSessionVars().StmtCtx, tp)
_, err = val.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), tp)
if err != nil && !types.ErrOverflow.Equal(err) {
return dbterror.ErrWrongTypeColumnValue.GenWithStackByArgs()
}
Expand Down
32 changes: 16 additions & 16 deletions pkg/executor/aggfuncs/aggfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func testMergePartialResult(t *testing.T, p aggTest) {
if p.funcName == ast.AggFuncJsonArrayagg {
dt = resultChk.GetRow(0).GetDatum(0, types.NewFieldType(mysql.TypeJSON))
}
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[0])

Expand All @@ -328,7 +328,7 @@ func testMergePartialResult(t *testing.T, p aggTest) {
if p.funcName == ast.AggFuncJsonArrayagg {
dt = resultChk.GetRow(0).GetDatum(0, types.NewFieldType(mysql.TypeJSON))
}
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[1])
_, err = finalFunc.MergePartialResult(ctx, partialResult, finalPr)
Expand All @@ -351,7 +351,7 @@ func testMergePartialResult(t *testing.T, p aggTest) {
if p.funcName == ast.AggFuncJsonArrayagg {
dt = resultChk.GetRow(0).GetDatum(0, types.NewFieldType(mysql.TypeJSON))
}
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[2], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[2], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[2])
}
Expand Down Expand Up @@ -410,7 +410,7 @@ func testMultiArgsMergePartialResult(t *testing.T, ctx sessionctx.Context, p mul
err = partialFunc.AppendFinalResult2Chunk(ctx, partialResult, resultChk)
require.NoError(t, err)
dt := resultChk.GetRow(0).GetDatum(0, p.retType)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Zero(t, result)

Expand All @@ -431,7 +431,7 @@ func testMultiArgsMergePartialResult(t *testing.T, ctx sessionctx.Context, p mul
err = partialFunc.AppendFinalResult2Chunk(ctx, partialResult, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, p.retType)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Zero(t, result)
_, err = finalFunc.MergePartialResult(ctx, partialResult, finalPr)
Expand All @@ -442,7 +442,7 @@ func testMultiArgsMergePartialResult(t *testing.T, ctx sessionctx.Context, p mul
require.NoError(t, err)

dt = resultChk.GetRow(0).GetDatum(0, p.retType)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[2], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[2], ctor)
require.NoError(t, err)
require.Zero(t, result)
}
Expand Down Expand Up @@ -540,7 +540,7 @@ func testAggFunc(t *testing.T, p aggTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt := resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[1])

Expand All @@ -550,7 +550,7 @@ func testAggFunc(t *testing.T, p aggTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[0])

Expand Down Expand Up @@ -583,7 +583,7 @@ func testAggFunc(t *testing.T, p aggTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[1])

Expand All @@ -593,7 +593,7 @@ func testAggFunc(t *testing.T, p aggTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Equalf(t, 0, result, "%v != %v", dt.String(), p.results[0])
}
Expand Down Expand Up @@ -630,7 +630,7 @@ func testAggFuncWithoutDistinct(t *testing.T, p aggTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt := resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Zerof(t, result, "%v != %v", dt.String(), p.results[1])

Expand All @@ -640,7 +640,7 @@ func testAggFuncWithoutDistinct(t *testing.T, p aggTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Zerof(t, result, "%v != %v", dt.String(), p.results[0])
}
Expand Down Expand Up @@ -708,7 +708,7 @@ func testMultiArgsAggFunc(t *testing.T, ctx sessionctx.Context, p multiArgsAggTe
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt := resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Zerof(t, result, "%v != %v", dt.String(), p.results[1])

Expand All @@ -718,7 +718,7 @@ func testMultiArgsAggFunc(t *testing.T, ctx sessionctx.Context, p multiArgsAggTe
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Zerof(t, result, "%v != %v", dt.String(), p.results[0])

Expand Down Expand Up @@ -751,7 +751,7 @@ func testMultiArgsAggFunc(t *testing.T, ctx sessionctx.Context, p multiArgsAggTe
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[1], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[1], ctor)
require.NoError(t, err)
require.Zerof(t, result, "%v != %v", dt.String(), p.results[1])

Expand All @@ -761,7 +761,7 @@ func testMultiArgsAggFunc(t *testing.T, ctx sessionctx.Context, p multiArgsAggTe
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt = resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[0], ctor)
result, err = dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[0], ctor)
require.NoError(t, err)
require.Zero(t, result)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/aggfuncs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ func buildLeadLag(ctx sessionctx.Context, aggFuncDesc *aggregation.AggFuncDesc,
if len(aggFuncDesc.Args) == 3 {
defaultExpr = aggFuncDesc.Args[2]
if et, ok := defaultExpr.(*expression.Constant); ok {
res, err1 := et.Value.ConvertTo(ctx.GetSessionVars().StmtCtx, aggFuncDesc.RetTp)
res, err1 := et.Value.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), aggFuncDesc.RetTp)
if err1 == nil {
defaultExpr = &expression.Constant{Value: res, RetType: aggFuncDesc.RetTp}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/aggfuncs/func_group_concat.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (h topNRows) Len() int {
func (h topNRows) Less(i, j int) bool {
n := len(h.rows[i].byItems)
for k := 0; k < n; k++ {
ret, err := h.rows[i].byItems[k].Compare(h.sctx.GetSessionVars().StmtCtx, h.rows[j].byItems[k], h.collators[k])
ret, err := h.rows[i].byItems[k].Compare(h.sctx.GetSessionVars().StmtCtx.TypeCtx(), h.rows[j].byItems[k], h.collators[k])
if err != nil {
h.err = err
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/aggfuncs/window_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func testWindowFunc(t *testing.T, p windowTest) {
err = finalFunc.AppendFinalResult2Chunk(ctx, finalPr, resultChk)
require.NoError(t, err)
dt := resultChk.GetRow(0).GetDatum(0, desc.RetTp)
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx, &p.results[i], collate.GetCollator(desc.RetTp.GetCollate()))
result, err := dt.Compare(ctx.GetSessionVars().StmtCtx.TypeCtx(), &p.results[i], collate.GetCollator(desc.RetTp.GetCollate()))
require.NoError(t, err)
require.Equal(t, 0, result)
resultChk.Reset()
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ import (
func checkHistogram(sc *stmtctx.StatementContext, hg *statistics.Histogram) (bool, error) {
for i := 0; i < len(hg.Buckets); i++ {
lower, upper := hg.GetLower(i), hg.GetUpper(i)
cmp, err := upper.Compare(sc, lower, collate.GetBinaryCollator())
cmp, err := upper.Compare(sc.TypeCtx(), lower, collate.GetBinaryCollator())
if cmp < 0 || err != nil {
return false, err
}
if i == 0 {
continue
}
previousUpper := hg.GetUpper(i - 1)
cmp, err = lower.Compare(sc, previousUpper, collate.GetBinaryCollator())
cmp, err = lower.Compare(sc.TypeCtx(), previousUpper, collate.GetBinaryCollator())
if cmp <= 0 || err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/foreign_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (fkc *FKCheckExec) updateRowNeedToCheck(sc *stmtctx.StatementContext, oldRo
if len(oldVals) == len(newVals) {
isSameValue := true
for i := range oldVals {
cmp, err := oldVals[i].Compare(sc, &newVals[i], collate.GetCollator(oldVals[i].Collation()))
cmp, err := oldVals[i].Compare(sc.TypeCtx(), &newVals[i], collate.GetCollator(oldVals[i].Collation()))
if err != nil || cmp != 0 {
isSameValue = false
break
Expand Down
6 changes: 3 additions & 3 deletions pkg/executor/index_lookup_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ func (iw *innerWorker) constructDatumLookupKey(task *lookUpJoinTask, chkIdx, row
return nil, nil, nil
}
innerColType := iw.rowTypes[iw.hashCols[i]]
innerValue, err := outerValue.ConvertTo(sc, innerColType)
innerValue, err := outerValue.ConvertTo(sc.TypeCtx(), innerColType)
if err != nil && !(terror.ErrorEqual(err, types.ErrTruncated) && (innerColType.GetType() == mysql.TypeSet || innerColType.GetType() == mysql.TypeEnum)) {
// If the converted outerValue overflows or invalid to innerValue, we don't need to lookup it.
if terror.ErrorEqual(err, types.ErrOverflow) || terror.ErrorEqual(err, types.ErrWarnDataOutOfRange) {
return nil, nil, nil
}
return nil, nil, err
}
cmp, err := outerValue.Compare(sc, &innerValue, iw.hashCollators[i])
cmp, err := outerValue.Compare(sc.TypeCtx(), &innerValue, iw.hashCollators[i])
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -675,7 +675,7 @@ func (iw *innerWorker) sortAndDedupLookUpContents(lookUpContents []*indexJoinLoo

func compareRow(sc *stmtctx.StatementContext, left, right []types.Datum, ctors []collate.Collator) int {
for idx := 0; idx < len(left); idx++ {
cmp, err := left[idx].Compare(sc, &right[idx], ctors[idx])
cmp, err := left[idx].Compare(sc.TypeCtx(), &right[idx], ctors[idx])
// We only compare rows with the same type, no error to return.
terror.Log(err)
if cmp > 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/index_lookup_merge_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ func (imw *innerMergeWorker) constructDatumLookupKey(task *lookUpMergeJoinTask,
return nil, nil
}
innerColType := imw.rowTypes[imw.keyCols[i]]
innerValue, err := outerValue.ConvertTo(sc, innerColType)
innerValue, err := outerValue.ConvertTo(sc.TypeCtx(), innerColType)
if err != nil {
// If the converted outerValue overflows, we don't need to lookup it.
if terror.ErrorEqual(err, types.ErrOverflow) || terror.ErrorEqual(err, types.ErrWarnDataOutOfRange) {
Expand All @@ -682,7 +682,7 @@ func (imw *innerMergeWorker) constructDatumLookupKey(task *lookUpMergeJoinTask,
}
return nil, err
}
cmp, err := outerValue.Compare(sc, &innerValue, imw.keyCollators[i])
cmp, err := outerValue.Compare(sc.TypeCtx(), &innerValue, imw.keyCollators[i])
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/insert_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ func (e *InsertValues) equalDatumsAsBinary(a []types.Datum, b []types.Datum) (bo
return false, nil
}
for i, ai := range a {
v, err := ai.Compare(e.Ctx().GetSessionVars().StmtCtx, &b[i], collate.GetBinaryCollator())
v, err := ai.Compare(e.Ctx().GetSessionVars().StmtCtx.TypeCtx(), &b[i], collate.GetBinaryCollator())
if err != nil {
return false, errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/union_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (ce compareExec) compare(sctx *stmtctx.StatementContext, a, b []types.Datum
for _, colOff := range ce.usedIndex {
aColumn := a[colOff]
bColumn := b[colOff]
cmp, err = aColumn.Compare(sctx, &bColumn, ce.collators[colOff])
cmp, err = aColumn.Compare(sctx.TypeCtx(), &bColumn, ce.collators[colOff])
if err != nil {
return 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func updateRecord(
// Compare datum, then handle some flags.
for i, col := range t.Cols() {
// We should use binary collation to compare datum, otherwise the result will be incorrect.
cmp, err := newData[i].Compare(sc, &oldData[i], collate.GetBinaryCollator())
cmp, err := newData[i].Compare(sc.TypeCtx(), &oldData[i], collate.GetBinaryCollator())
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/aggregation/bit_and.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (bf *bitAndFunction) Update(evalCtx *AggEvaluateContext, sc *stmtctx.Statem
if value.Kind() == types.KindUint64 {
evalCtx.Value.SetUint64(evalCtx.Value.GetUint64() & value.GetUint64())
} else {
int64Value, err := value.ToInt64(sc)
int64Value, err := value.ToInt64(sc.TypeCtx())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/aggregation/bit_or.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (bf *bitOrFunction) Update(evalCtx *AggEvaluateContext, sc *stmtctx.Stateme
if value.Kind() == types.KindUint64 {
evalCtx.Value.SetUint64(evalCtx.Value.GetUint64() | value.GetUint64())
} else {
int64Value, err := value.ToInt64(sc)
int64Value, err := value.ToInt64(sc.TypeCtx())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/aggregation/bit_xor.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (bf *bitXorFunction) Update(evalCtx *AggEvaluateContext, sc *stmtctx.Statem
if value.Kind() == types.KindUint64 {
evalCtx.Value.SetUint64(evalCtx.Value.GetUint64() ^ value.GetUint64())
} else {
int64Value, err := value.ToInt64(sc)
int64Value, err := value.ToInt64(sc.TypeCtx())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/aggregation/max_min.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (mmf *maxMinFunction) Update(evalCtx *AggEvaluateContext, sc *stmtctx.State
return nil
}
var c int
c, err = evalCtx.Value.Compare(sc, &value, mmf.ctor)
c, err = evalCtx.Value.Compare(sc.TypeCtx(), &value, mmf.ctor)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/builtin_cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func (b *builtinCastIntAsTimeSig) evalTime(row chunk.Row) (res types.Time, isNul
}

if b.args[0].GetType().GetType() == mysql.TypeYear {
res, err = types.ParseTimeFromYear(b.ctx.GetSessionVars().StmtCtx, val)
res, err = types.ParseTimeFromYear(val)
} else {
res, err = types.ParseTimeFromNum(b.ctx.GetSessionVars().StmtCtx.TypeCtx(), val, b.tp.GetType(), b.tp.GetDecimal())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (b *builtinCastIntAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk.
}

if b.args[0].GetType().GetType() == mysql.TypeYear {
tm, err = types.ParseTimeFromYear(stmt, i64s[i])
tm, err = types.ParseTimeFromYear(i64s[i])
} else {
tm, err = types.ParseTimeFromNum(stmt.TypeCtx(), i64s[i], b.tp.GetType(), fsp)
}
Expand Down
Loading