Skip to content

Commit 06d5483

Browse files
committed
changed mc.buf == nil to mc.netConn == nil
1 parent 32e5cee commit 06d5483

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

connection.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (mc *mysqlConn) handleParams() (err error) {
9999
}
100100

101101
func (mc *mysqlConn) Begin() (driver.Tx, error) {
102-
if mc.buf == nil {
102+
if mc.netConn == nil {
103103
return nil, errInvalidConn
104104
}
105105
err := mc.exec("START TRANSACTION")
@@ -111,9 +111,6 @@ func (mc *mysqlConn) Begin() (driver.Tx, error) {
111111
}
112112

113113
func (mc *mysqlConn) Close() (err error) {
114-
if mc.buf == nil {
115-
return errInvalidConn
116-
}
117114
// Makes Close idempotent
118115
if mc.netConn != nil {
119116
mc.writeCommandPacket(comQuit)
@@ -128,7 +125,7 @@ func (mc *mysqlConn) Close() (err error) {
128125
}
129126

130127
func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
131-
if mc.buf == nil {
128+
if mc.netConn == nil {
132129
return nil, errInvalidConn
133130
}
134131
// Send command
@@ -159,7 +156,7 @@ func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
159156
}
160157

161158
func (mc *mysqlConn) Exec(query string, args []driver.Value) (driver.Result, error) {
162-
if mc.buf == nil {
159+
if mc.netConn == nil {
163160
return nil, errInvalidConn
164161
}
165162
if len(args) == 0 { // no args, fastpath
@@ -203,7 +200,7 @@ func (mc *mysqlConn) exec(query string) error {
203200
}
204201

205202
func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, error) {
206-
if mc.buf == nil {
203+
if mc.netConn == nil {
207204
return nil, errInvalidConn
208205
}
209206
if len(args) == 0 { // no args, fastpath

rows.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (rows *mysqlRows) Columns() []string {
3737
func (rows *mysqlRows) Close() (err error) {
3838
// Remove unread packets from stream
3939
if !rows.eof {
40-
if rows.mc == nil || rows.mc.buf == nil {
40+
if rows.mc == nil || rows.mc.netConn == nil {
4141
return errInvalidConn
4242
}
4343

@@ -58,7 +58,7 @@ func (rows *mysqlRows) Next(dest []driver.Value) (err error) {
5858
return io.EOF
5959
}
6060

61-
if rows.mc == nil || rows.mc.buf == nil {
61+
if rows.mc == nil || rows.mc.netConn == nil {
6262
return errInvalidConn
6363
}
6464

statement.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (stmt *mysqlStmt) NumInput() int {
3434
}
3535

3636
func (stmt *mysqlStmt) Exec(args []driver.Value) (driver.Result, error) {
37-
if stmt.mc.buf == nil {
37+
if stmt.mc.netConn == nil {
3838
return nil, errInvalidConn
3939
}
4040
// Send command
@@ -73,7 +73,7 @@ func (stmt *mysqlStmt) Exec(args []driver.Value) (driver.Result, error) {
7373
}
7474

7575
func (stmt *mysqlStmt) Query(args []driver.Value) (driver.Rows, error) {
76-
if stmt.mc.buf == nil {
76+
if stmt.mc.netConn == nil {
7777
return nil, errInvalidConn
7878
}
7979
// Send command

transaction.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type mysqlTx struct {
1313
}
1414

1515
func (tx *mysqlTx) Commit() (err error) {
16-
if tx.mc == nil || tx.mc.buf == nil {
16+
if tx.mc == nil || tx.mc.netConn == nil {
1717
return errInvalidConn
1818
}
1919
err = tx.mc.exec("COMMIT")
@@ -22,7 +22,7 @@ func (tx *mysqlTx) Commit() (err error) {
2222
}
2323

2424
func (tx *mysqlTx) Rollback() (err error) {
25-
if tx.mc == nil || tx.mc.buf == nil {
25+
if tx.mc == nil || tx.mc.netConn == nil {
2626
return errInvalidConn
2727
}
2828
err = tx.mc.exec("ROLLBACK")

0 commit comments

Comments
 (0)