Skip to content

Commit

Permalink
replace gomysql with mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
djshow832 committed Dec 15, 2023
1 parent 2e20a48 commit f057a30
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pkg/proxy/backend/backend_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"unsafe"

"github.com/cenkalti/backoff/v4"
gomysql "github.com/go-mysql-org/go-mysql/mysql"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/tiproxy/lib/config"
"github.com/pingcap/tiproxy/lib/util/errors"
"github.com/pingcap/tiproxy/lib/util/waitgroup"
Expand Down Expand Up @@ -264,7 +264,7 @@ func (mgr *BackendConnManager) ExecuteCmd(ctx context.Context, request []byte) (
mgr.handshakeHandler.OnTraffic(mgr)
}()
if len(request) < 1 {
err = gomysql.ErrMalformPacket
err = mysql.ErrMalformPacket
return
}
cmd := pnet.Command(request[0])
Expand Down Expand Up @@ -304,7 +304,7 @@ func (mgr *BackendConnManager) ExecuteCmd(ctx context.Context, request []byte) (
mgr.authenticator.capability &^= pnet.ClientMultiStatements
mgr.cmdProcessor.capability &^= pnet.ClientMultiStatements
default:
err = errors.Wrapf(gomysql.ErrMalformPacket, "unrecognized set_option value:%d", val)
err = errors.Wrapf(mysql.ErrMalformPacket, "unrecognized set_option value:%d", val)
return
}
case pnet.ComChangeUser:
Expand Down Expand Up @@ -359,7 +359,7 @@ func (mgr *BackendConnManager) initSessionStates(backendIO *pnet.PacketIO, sessi

func (mgr *BackendConnManager) querySessionStates(backendIO *pnet.PacketIO) (sessionStates, sessionToken string, err error) {
// Do not lock here because the caller already locks.
var result *gomysql.Resultset
var result *mysql.Resultset
if result, _, err = mgr.cmdProcessor.query(backendIO, sqlQueryState); err != nil {
return
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/proxy/backend/handshake_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package backend

import (
gomysql "github.com/go-mysql-org/go-mysql/mysql"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/tiproxy/lib/util/errors"
"github.com/pingcap/tiproxy/pkg/manager/namespace"
"github.com/pingcap/tiproxy/pkg/manager/router"
Expand Down Expand Up @@ -38,7 +38,7 @@ type ConnContext interface {

type HandshakeHandler interface {
HandleHandshakeResp(ctx ConnContext, resp *pnet.HandshakeResp) error
HandleHandshakeErr(ctx ConnContext, err *gomysql.MyError) bool // return true means retry connect
HandleHandshakeErr(ctx ConnContext, err *mysql.MyError) bool // return true means retry connect
GetRouter(ctx ConnContext, resp *pnet.HandshakeResp) (router.Router, error)
OnHandshake(ctx ConnContext, to string, err error, src ErrorSource)
OnConnClose(ctx ConnContext, src ErrorSource) error
Expand All @@ -61,7 +61,7 @@ func (handler *DefaultHandshakeHandler) HandleHandshakeResp(ConnContext, *pnet.H
return nil
}

func (handler *DefaultHandshakeHandler) HandleHandshakeErr(ctx ConnContext, err *gomysql.MyError) bool {
func (handler *DefaultHandshakeHandler) HandleHandshakeErr(ctx ConnContext, err *mysql.MyError) bool {
return false
}

Expand Down Expand Up @@ -110,7 +110,7 @@ type CustomHandshakeHandler struct {
onTraffic func(ConnContext)
onConnClose func(ConnContext, ErrorSource) error
handleHandshakeResp func(ctx ConnContext, resp *pnet.HandshakeResp) error
handleHandshakeErr func(ctx ConnContext, err *gomysql.MyError) bool
handleHandshakeErr func(ctx ConnContext, err *mysql.MyError) bool
getCapability func() pnet.Capability
getServerVersion func() string
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func (h *CustomHandshakeHandler) HandleHandshakeResp(ctx ConnContext, resp *pnet
return nil
}

func (h *CustomHandshakeHandler) HandleHandshakeErr(ctx ConnContext, err *gomysql.MyError) bool {
func (h *CustomHandshakeHandler) HandleHandshakeErr(ctx ConnContext, err *mysql.MyError) bool {
if h.handleHandshakeErr != nil {
return h.handleHandshakeErr(ctx, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/proxy/backend/mock_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"testing"

gomysql "github.com/go-mysql-org/go-mysql/mysql"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/tiproxy/lib/util/logger"
pnet "github.com/pingcap/tiproxy/pkg/proxy/net"
"go.uber.org/zap"
Expand Down Expand Up @@ -39,7 +39,7 @@ type mockProxy struct {

*proxyConfig
// outputs that received from the server.
rs *gomysql.Resultset
rs *mysql.Resultset
// execution results
err error
logger *zap.Logger
Expand Down
4 changes: 2 additions & 2 deletions pkg/proxy/net/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package net
import (
"testing"

gomysql "github.com/go-mysql-org/go-mysql/mysql"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/pingcap/tiproxy/lib/util/errors"
"github.com/pingcap/tiproxy/lib/util/logger"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestLogAttrs(t *testing.T) {
}

func TestMySQLError(t *testing.T) {
myerr := &gomysql.MyError{}
myerr := &mysql.MyError{}
require.True(t, IsMySQLError(errors.Wrap(ErrHandshakeTLS, myerr)))
require.False(t, IsMySQLError(errors.Wrap(myerr, ErrHandshakeTLS)))
require.False(t, IsMySQLError(ErrHandshakeTLS))
Expand Down

0 comments on commit f057a30

Please sign in to comment.