server: tiny refactor, more go style (#11478)

This commit is contained in:
goroutine
2019-08-01 17:36:05 +08:00
committed by pingcap-github-bot
parent 10e8498dd6
commit 7715341cb7
2 changed files with 3 additions and 11 deletions

View File

@ -447,7 +447,6 @@ func (e *InsertValues) fillColValue(ctx context.Context, datum types.Datum, idx
// fillRow fills generated columns, auto_increment column and empty column.
// For NOT NULL column, it will return error or use zero value based on sql_mode.
func (e *InsertValues) fillRow(ctx context.Context, row []types.Datum, hasValue []bool) ([]types.Datum, error) {
gIdx := 0
gCols := make([]*table.Column, 0)
for i, c := range e.Table.Cols() {
var err error
@ -466,12 +465,9 @@ func (e *InsertValues) fillRow(ctx context.Context, row []types.Datum, hasValue
}
}
}
for _, gCol := range gCols {
var err error
var val types.Datum
for i, gCol := range gCols {
colIdx := gCol.ColumnInfo.Offset
val, err = e.GenExprs[gIdx].Eval(chunk.MutRowFromDatums(row).ToRow())
gIdx++
val, err := e.GenExprs[i].Eval(chunk.MutRowFromDatums(row).ToRow())
if e.filterErr(err) != nil {
return nil, err
}

View File

@ -121,9 +121,8 @@ type Server struct {
// ConnectionCount gets current connection count.
func (s *Server) ConnectionCount() int {
var cnt int
s.rwlock.RLock()
cnt = len(s.clients)
cnt := len(s.clients)
s.rwlock.RUnlock()
return cnt
}
@ -294,7 +293,6 @@ func (s *Server) loadTLSCertificates() {
Certificates: []tls.Certificate{tlsCert},
ClientCAs: certPool,
ClientAuth: clientAuthPolicy,
MinVersion: 0,
}
}
@ -471,11 +469,9 @@ func (cc *clientConn) connectInfo() *variable.ConnectionInfo {
ClientPort: cc.peerPort,
ServerID: 1,
ServerPort: int(cc.server.cfg.Port),
Duration: 0,
User: cc.user,
ServerOSLoginUser: osUser,
OSVersion: osVersion,
ClientVersion: "",
ServerVersion: mysql.TiDBReleaseVersion,
SSLVersion: "v1.2.0", // for current go version
PID: serverPID,