Skip to content

Commit

Permalink
fix charset error
Browse files Browse the repository at this point in the history
  • Loading branch information
teckick committed Dec 18, 2020
1 parent 0d01823 commit db6ec34
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/proxy/backend/client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"time"

"github.com/pingcap-incubator/weir/pkg/proxy/constant"
"github.com/pingcap/errors"
. "github.com/siddontang/go-mysql/mysql"
"github.com/siddontang/go-mysql/packet"
Expand Down Expand Up @@ -65,8 +66,8 @@ func Connect(addr string, user string, password string, dbName string, options .
c.db = dbName
c.proto = proto

//use default charset here, utf-8
c.charset = DEFAULT_CHARSET
//use default charset here
c.charset = constant.DefaultCharset

// Apply configuration functions.
for i := range options {
Expand Down
8 changes: 8 additions & 0 deletions pkg/proxy/constant/charset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package constant

import "github.com/pingcap/parser/charset"

const (
DefaultCharset = charset.CharsetUTF8MB4
DefaultCollationID = charset.CollationUTF8MB4
)
3 changes: 3 additions & 0 deletions pkg/proxy/driver/sessionvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (s *SessionVarsWrapper) SetSystemVarAST(name string, v *ast.VariableAssignm
}

func (s *SessionVarsWrapper) CheckSessionSysVarValid(name string) error {
if name == ast.SetNames || name == ast.SetCharset {
return nil
}
sysVar := variable.GetSysVar(name)
if sysVar == nil {
return fmt.Errorf("%s is not a valid sysvar", name)
Expand Down

0 comments on commit db6ec34

Please sign in to comment.