Skip to content

Commit

Permalink
Clean up code style around upstream server changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jscheinblum committed Nov 3, 2023
1 parent db3262e commit 3781ce9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 4 additions & 1 deletion go/mysql/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ type Conn struct {
// It is set during the initial handshake.
UserData Getter

ConnectionAttributes map[string]string
// ConnectionAttributes stores attributes set in the connection phase when
// attributes from the client are sent. This is arbitrary key/value pairs
// sent by the client.
ConnectionAttributes ConnectionAttributesMap

bufferedReader *bufio.Reader
flushTimer *time.Timer
Expand Down
4 changes: 4 additions & 0 deletions go/mysql/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const (
// implemented authentication methods.
type AuthMethodDescription string

// Map of client key/value pairs sent by the client during
// the connection phase
type ConnectionAttributesMap map[string]string

// Supported auth forms.
const (
// MysqlNativePassword uses a salt and transmits a hash on the wire.
Expand Down
12 changes: 6 additions & 6 deletions go/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,9 @@ func (c *Conn) writeHandshakeV10(serverVersion string, authServer AuthServer, en
}

// parseClientHandshakePacket parses the handshake sent by the client.
// Returns the username, auth method, auth data, error.
// Returns the username, auth method, auth data, connection attributes, error.
// The original data is not pointed at, and can be freed.
func (l *Listener) parseClientHandshakePacket(c *Conn, firstTime bool, data []byte) (string, AuthMethodDescription, []byte, map[string]string, error) {
func (l *Listener) parseClientHandshakePacket(c *Conn, firstTime bool, data []byte) (string, AuthMethodDescription, []byte, ConnectionAttributesMap, error) {
pos := 0

// Client flags, 4 bytes.
Expand Down Expand Up @@ -755,20 +755,20 @@ func (l *Listener) parseClientHandshakePacket(c *Conn, firstTime bool, data []by
}

// Decode connection attributes send by the client
var client_attibutes map[string]string
var clientAttributes map[string]string
if clientFlags&CapabilityClientConnAttr != 0 {
ca, _, err := parseConnAttrs(data, pos)
if err != nil {
log.Warningf("Decode connection attributes send by the client: %v", err)
}

client_attibutes = ca
clientAttributes = ca
}

return username, AuthMethodDescription(authMethod), authResponse, client_attibutes, nil
return username, AuthMethodDescription(authMethod), authResponse, clientAttributes, nil
}

func parseConnAttrs(data []byte, pos int) (map[string]string, int, error) {
func parseConnAttrs(data []byte, pos int) (ConnectionAttributesMap, int, error) {
var attrLen uint64

attrLen, pos, ok := readLenEncInt(data, pos)
Expand Down
2 changes: 0 additions & 2 deletions go/vt/vtgateproxy/vtgateproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ func (proxy *VTGateProxy) Prepare(ctx context.Context, session *vtgateconn.VTGat
}

func (proxy *VTGateProxy) Execute(ctx context.Context, session *vtgateconn.VTGateSession, sql string, bindVariables map[string]*querypb.BindVariable) (qr *sqltypes.Result, err error) {
log.Infof("Execute %s", sql)

if proxy.conn == nil {
return nil, vterrors.Errorf(vtrpcpb.Code_UNAVAILABLE, "not connnected")
}
Expand Down

0 comments on commit 3781ce9

Please sign in to comment.