Skip to content

Commit 4e1d823

Browse files
committed
refactoring and micro-optimisation
1 parent ccad956 commit 4e1d823

7 files changed

+248
-323
lines changed

connection.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import (
1818

1919
type mysqlConn struct {
2020
cfg *config
21-
server *serverSettings
21+
flags ClientFlag
22+
charset byte
23+
scrambleBuff []byte
2224
netConn net.Conn
2325
buf *buffer
2426
protocol uint8
@@ -36,15 +38,6 @@ type config struct {
3638
params map[string]string
3739
}
3840

39-
type serverSettings struct {
40-
protocol byte
41-
version string
42-
flags ClientFlag
43-
charset uint8
44-
scrambleBuff []byte
45-
threadID uint32
46-
}
47-
4841
// Handles parameters set in DSN
4942
func (mc *mysqlConn) handleParams() (err error) {
5043
for param, val := range mc.cfg.params {

driver_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func TestString(t *testing.T) {
301301
if rows.Next() {
302302
rows.Scan(&out)
303303
if in != out {
304-
t.Errorf("%s: %d != %d", v, in, out)
304+
t.Errorf("%s: %s != %s", v, in, out)
305305
}
306306
} else {
307307
t.Errorf("%s: no data", v)

errors.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2+
//
3+
// Copyright 2013 Julien Schmidt. All rights reserved.
4+
// http://www.julienschmidt.com
5+
//
6+
// This Source Code Form is subject to the terms of the Mozilla Public
7+
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
8+
// You can obtain one at http://mozilla.org/MPL/2.0/.
9+
10+
package mysql
11+
12+
import "errors"
13+
14+
var (
15+
errMalformPkt = errors.New("Malformed Packet")
16+
errPktSync = errors.New("Commands out of sync. You can't run this command now")
17+
errPktSyncMul = errors.New("Commands out of sync. Did you run multiple statements at once?")
18+
errOldPassword = errors.New("It seems like you are using old_passwords, which is unsupported. See https://github.com/Go-SQL-Driver/MySQL/wiki/old_passwords")
19+
)

0 commit comments

Comments
 (0)