From 6766b7632ebdbf1db114122c32826511852c1f1f Mon Sep 17 00:00:00 2001 From: Lingyu Song Date: Sat, 4 Apr 2020 16:02:15 +0800 Subject: [PATCH] expression: fix charset and collation for `current_role` (#16019) --- expression/builtin_info.go | 1 + expression/typeinfer_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/expression/builtin_info.go b/expression/builtin_info.go index fa945845d3e82..f513cf10f6fd3 100644 --- a/expression/builtin_info.go +++ b/expression/builtin_info.go @@ -170,6 +170,7 @@ func (c *currentRoleFunctionClass) getFunction(ctx sessionctx.Context, args []Ex return nil, err } bf := newBaseBuiltinFuncWithTp(ctx, args, types.ETString) + bf.tp.Charset, bf.tp.Collate = ctx.GetSessionVars().GetCharsetInfo() bf.tp.Flen = 64 sig := &builtinCurrentRoleSig{bf} return sig, nil diff --git a/expression/typeinfer_test.go b/expression/typeinfer_test.go index 129e237a11262..b5ecc82b038e2 100644 --- a/expression/typeinfer_test.go +++ b/expression/typeinfer_test.go @@ -843,6 +843,7 @@ func (s *testInferTypeSuite) createTestCase4InfoFunc() []typeInferTestCase { {"found_rows()", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag | mysql.UnsignedFlag, mysql.MaxIntWidth, 0}, {"database()", mysql.TypeVarString, charset.CharsetUTF8MB4, 0, 64, types.UnspecifiedLength}, {"current_user()", mysql.TypeVarString, charset.CharsetUTF8MB4, 0, 64, types.UnspecifiedLength}, + {"current_role()", mysql.TypeVarString, charset.CharsetUTF8MB4, 0, 64, types.UnspecifiedLength}, {"user()", mysql.TypeVarString, charset.CharsetUTF8MB4, 0, 64, types.UnspecifiedLength}, {"connection_id()", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag | mysql.UnsignedFlag, mysql.MaxIntWidth, 0}, {"version()", mysql.TypeVarString, charset.CharsetUTF8MB4, 0, 64, types.UnspecifiedLength},