Skip to content

Commit 5cb5fdc

Browse files
committed
tweak rows.Close() err handling; fix VividCortex#46
1 parent aa73780 commit 5cb5fdc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

retrieving.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ First, as long as there's an open result set (represented by `rows`), the
6565
underlying connection is busy and can't be used for any other query. That means
6666
it's not available in the connection pool. If you iterate over all of the rows
6767
with `rows.Next()`, eventually you'll read the last row, and `rows.Next()` will
68-
encounter an internal EOF error and call `rows.Close()` for you. But if for any
69-
reason you exit that loop -- an error, an early return, or so on -- then the
70-
`rows` doesn't get closed, and the connection remains open. This is an easy way
68+
encounter an internal EOF error and call `rows.Close()` for you. But if for some
69+
reason you exit that loop -- an early return, or so on -- then the
70+
`rows` doesn't get closed, and the connection remains open. (It is auto-closed
71+
if `rows.Next()` returns false due to an error, though). This is an easy way
7172
to run out of resources. This is why **you should always `defer rows.Close()`**,
7273
even if you also call it explicitly at the end of the loop, which isn't a bad
7374
idea. `rows.Close()` is a harmless no-op if it's already closed, so you can call

0 commit comments

Comments
 (0)