Skip to content

Commit 91054db

Browse files
committed
binaryRows: both EOF and MySQLErrors set rows.mc = nil, not just EOF
1 parent 9543750 commit 91054db

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

rows.go

+21-8
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,31 @@ func (rows *mysqlRows) Close() error {
5959
}
6060

6161
func (rows *binaryRows) Next(dest []driver.Value) error {
62-
if mc := rows.mc; mc != nil {
63-
if mc.netConn == nil {
64-
return ErrInvalidConn
65-
}
62+
if rows.mc == nil {
63+
return io.EOF
64+
}
6665

67-
// Fetch next row from stream
68-
if err := rows.readRow(dest); err != io.EOF {
69-
return err
66+
mc := rows.mc
67+
if mc.netConn == nil {
68+
return ErrInvalidConn
69+
}
70+
71+
// Fetch next row from stream
72+
err := rows.readRow(dest)
73+
done := false
74+
if err != nil {
75+
if err == io.EOF {
76+
done = true
77+
}
78+
if _, ok := err.(*MySQLError); ok {
79+
done = true
7080
}
81+
}
82+
if done {
7183
rows.mc = nil
7284
}
73-
return io.EOF
85+
86+
return err
7487
}
7588

7689
func (rows *textRows) Next(dest []driver.Value) error {

0 commit comments

Comments
 (0)