Skip to content

Commit

Permalink
revert #15125
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 committed Aug 28, 2024
1 parent d041cd0 commit 3d7ee76
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
9 changes: 1 addition & 8 deletions pkg/expression/expr_to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,13 @@ func (pc PbConverter) scalarFuncToPBExpr(expr *ScalarFunction) *tipb.Expr {
}
}

// put collation information into the RetType enforcedly and push it down to TiKV/MockTiKV
tp := *expr.RetType
if collate.NewCollationEnabled() {
_, str1 := expr.CharsetAndCollation()
tp.SetCollate(str1)
}

// Construct expression ProtoBuf.
return &tipb.Expr{
Tp: tipb.ExprType_ScalarFunc,
Val: encoded,
Sig: pbCode,
Children: children,
FieldType: ToPBFieldType(&tp),
FieldType: ToPBFieldType(expr.RetType),
}
}

Expand Down
18 changes: 0 additions & 18 deletions pkg/expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1755,24 +1755,6 @@ func TestSortByItem2Pb(t *testing.T) {
require.Equal(t, "{\"expr\":{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":5,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\",\"array\":false},\"has_distinct\":false},\"desc\":true}", string(js))
}

func TestPushCollationDown(t *testing.T) {
ctx := mock.NewContext()
fc, err := NewFunction(ctx, ast.EQ, types.NewFieldType(mysql.TypeUnspecified), genColumn(mysql.TypeVarchar, 0), genColumn(mysql.TypeVarchar, 1))
require.NoError(t, err)
client := new(mock.Client)

tps := []*types.FieldType{types.NewFieldType(mysql.TypeVarchar), types.NewFieldType(mysql.TypeVarchar)}
for _, coll := range []string{charset.CollationBin, charset.CollationLatin1, charset.CollationUTF8, charset.CollationUTF8MB4} {
fc.SetCharsetAndCollation("binary", coll) // only collation matters
pbExpr, err := ExpressionsToPBList(ctx, []Expression{fc}, client)
require.NoError(t, err)
expr, err := PBToExpr(ctx, pbExpr[0], tps)
require.NoError(t, err)
_, eColl := expr.CharsetAndCollation()
require.Equal(t, coll, eColl)
}
}

func columnCollation(c *Column, chs, coll string) *Column {
c.RetType.SetCharset(chs)
c.RetType.SetCollate(coll)
Expand Down

0 comments on commit 3d7ee76

Please sign in to comment.