diff --git a/server/conn.go b/server/conn.go index 19bdae8ba..2e819309c 100644 --- a/server/conn.go +++ b/server/conn.go @@ -107,11 +107,11 @@ func (c *Conn) handshake() error { if err := c.readHandshakeResponse(); err != nil { if errors.Is(err, ErrAccessDenied) { - usingPasswd := ER_YES + var usingPasswd uint16 = ER_YES if errors.Is(err, ErrAccessDeniedNoPassword) { usingPasswd = ER_NO } - err = NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), usingPasswd) + err = NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), MySQLErrName[usingPasswd]) } _ = c.writeError(err) return err diff --git a/server/handshake_resp.go b/server/handshake_resp.go index f2777bb7e..efdf511e5 100644 --- a/server/handshake_resp.go +++ b/server/handshake_resp.go @@ -148,7 +148,7 @@ func (c *Conn) readAuthData(data []byte, pos int) (auth []byte, authLen int, new } if isNULL { // no auth length and no auth data, just \NUL, considered invalid auth data, and reject connection as MySQL does - return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.RemoteAddr().String(), c.user, ER_NO) + return nil, 0, 0, NewDefaultError(ER_ACCESS_DENIED_ERROR, c.user, c.RemoteAddr().String(), MySQLErrName[ER_NO]) } auth = authData authLen = readBytes