On Wed, Feb 21, 2024 at 4:27 PM Marco De Zio <marco.de...@gmail.com> wrote: > > It seems to me that the second flag returned by Rows.nextLocked is wrongly > interpreted by Rows.Next as it sets rs.hitEOF = true when ok is false; also > Rows.nextLocked should set ok to true in some of the cases where right now > returns false. > > Reference in code: > https://github.com/golang/go/blob/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98/src/database/sql/sql.go#L3027 > > Am I wrong ?
The "ok" result of nextLocked is intended to report whether, when the method returns, the Rows is pointing at valid data. The "doClose" result reports whether the Rows should be closed. Given that understanding, the behavior of Next looks reasonable to me. As it happens when the current implementation returns "doClose" as true, it always returns "ok" as false. So the test "if doClose && !ok" is not strictly necessary; it could be replaced with "if doClose". But the current code doesn't seem wrong to me. Can you show a code sequence that seems buggy to you? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUUvSzDWim4dijEUcP5U2vx_xj_T-Y9SFczS4qMWuJFfQ%40mail.gmail.com.