Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small refactoring in rows.go #103

Merged
merged 2 commits into from
Jul 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

var (
errInvalidConn = errors.New("Invalid Connection")
errMalformPkt = errors.New("Malformed Packet")
errNoTLS = errors.New("TLS encryption requested but server does not support TLS")
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")
Expand Down
14 changes: 5 additions & 9 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package mysql

import (
"database/sql/driver"
"errors"
"io"
)

Expand All @@ -37,33 +36,30 @@ func (rows *mysqlRows) Columns() (columns []string) {
}

func (rows *mysqlRows) Close() (err error) {
defer func() {
rows.mc = nil
}()

// Remove unread packets from stream
if !rows.eof {
if rows.mc == nil {
return errors.New("Invalid Connection")
return errInvalidConn
}

err = rows.mc.readUntilEOF()
}

rows.mc = nil

return
}

func (rows *mysqlRows) Next(dest []driver.Value) error {
func (rows *mysqlRows) Next(dest []driver.Value) (err error) {
if rows.eof {
return io.EOF
}

if rows.mc == nil {
return errors.New("Invalid Connection")
return errInvalidConn
}

// Fetch next row from stream
var err error
if rows.binary {
err = rows.readBinaryRow(dest)
} else {
Expand Down