Skip to content

Commit

Permalink
make test stable
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao committed Sep 25, 2024
1 parent 1707848 commit 12c8658
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/expression/exprstatic/evalctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,35 @@ func (ctx *EvalContext) currentTimeFuncFromStringVal(val string) func() (time.Ti

func newSessionVarsWithSystemVariables(vars map[string]string) (*variable.SessionVars, error) {
sessionVars := variable.NewSessionVars(nil)
var cs, col []string
for name, val := range vars {
if err := sessionVars.SetSystemVar(name, val); err != nil {
switch strings.ToLower(name) {
// `charset_connection` and `collation_connection` will overwrite each other.
// To make the result more determinate, just set them at last step in order:
// `charset_connection` first, then `collation_connection`.
case variable.CharacterSetConnection:
cs = []string{name, val}
case variable.CollationConnection:
col = []string{name, val}
default:
if err := sessionVars.SetSystemVar(name, val); err != nil {
return nil, err
}
}
}

if cs != nil {
if err := sessionVars.SetSystemVar(cs[0], cs[1]); err != nil {
return nil, err
}
}

if col != nil {
if err := sessionVars.SetSystemVar(col[0], col[1]); err != nil {
return nil, err
}
}

return sessionVars, nil
}

Expand Down

0 comments on commit 12c8658

Please sign in to comment.