(*sql.Rows).Next() can return false due to an error. The error must be handled by checking (*sql.Rows).Err().
The transaction must be ended by commit or rollback to close the db connection. Calling rollback after commit is noop.
Don't call a query in the middle of cursor, as it may lead to a deadlock. The inner query may wait for a free connection, and the connection from the cursor can't be freed because it's stuck by the inner query waiting.
(*sql.Rows).Next()
can returnfalse
due to an error. The error must be handled by checking(*sql.Rows).Err()
.The transaction must be ended by commit or rollback to close the db connection. Calling rollback after commit is noop.
Don't call a query in the middle of cursor, as it may lead to a deadlock. The inner query may wait for a free connection, and the connection from the cursor can't be freed because it's stuck by the inner query waiting.