|
|
@@ -24,8 +24,8 @@ type mysqlField struct {
|
|
|
type rowsContent struct {
|
|
|
mc *mysqlConn
|
|
|
binary bool
|
|
|
- unread int
|
|
|
columns []mysqlField
|
|
|
+ eof bool
|
|
|
}
|
|
|
|
|
|
type mysqlRows struct {
|
|
|
@@ -47,7 +47,7 @@ func (rows mysqlRows) Close() (e error) {
|
|
|
}()
|
|
|
|
|
|
// Remove unread packets from stream
|
|
|
- if rows.content.unread > -1 {
|
|
|
+ if !rows.content.eof {
|
|
|
if rows.content.mc == nil {
|
|
|
return errors.New("Invalid Connection")
|
|
|
}
|
|
|
@@ -66,36 +66,38 @@ func (rows mysqlRows) Close() (e error) {
|
|
|
// when the dest type is know, which makes type conversion easier and avoids
|
|
|
// unnecessary conversions.
|
|
|
func (rows mysqlRows) Next(dest []driver.Value) error {
|
|
|
- if rows.content.unread > 0 {
|
|
|
- if rows.content.mc == nil {
|
|
|
- return errors.New("Invalid Connection")
|
|
|
- }
|
|
|
+ if rows.content.eof {
|
|
|
+ return io.EOF
|
|
|
+ }
|
|
|
|
|
|
- columnsCount := cap(dest)
|
|
|
+ if rows.content.mc == nil {
|
|
|
+ return errors.New("Invalid Connection")
|
|
|
+ }
|
|
|
|
|
|
- // Fetch next row from stream
|
|
|
- var row *[]*[]byte
|
|
|
- var e error
|
|
|
- if rows.content.binary {
|
|
|
- row, e = rows.content.mc.readBinaryRow(rows.content)
|
|
|
- } else {
|
|
|
- row, e = rows.content.mc.readRow(columnsCount)
|
|
|
- }
|
|
|
- rows.content.unread--
|
|
|
+ columnsCount := cap(dest)
|
|
|
|
|
|
- if e != nil {
|
|
|
- return e
|
|
|
+ // Fetch next row from stream
|
|
|
+ var row *[]*[]byte
|
|
|
+ var e error
|
|
|
+ if rows.content.binary {
|
|
|
+ row, e = rows.content.mc.readBinaryRow(rows.content)
|
|
|
+ } else {
|
|
|
+ row, e = rows.content.mc.readRow(columnsCount)
|
|
|
+ }
|
|
|
+
|
|
|
+ if e != nil {
|
|
|
+ if e == io.EOF {
|
|
|
+ rows.content.eof = true
|
|
|
}
|
|
|
+ return e
|
|
|
+ }
|
|
|
|
|
|
- for i := 0; i < columnsCount; i++ {
|
|
|
- if (*row)[i] == nil {
|
|
|
- dest[i] = nil
|
|
|
- } else {
|
|
|
- dest[i] = *(*row)[i]
|
|
|
- }
|
|
|
+ for i := 0; i < columnsCount; i++ {
|
|
|
+ if (*row)[i] == nil {
|
|
|
+ dest[i] = nil
|
|
|
+ } else {
|
|
|
+ dest[i] = *(*row)[i]
|
|
|
}
|
|
|
- } else {
|
|
|
- return io.EOF
|
|
|
}
|
|
|
|
|
|
return nil
|