Add a check to rows.Err after processing all rows by ajm188 · Pull Request #835 · github/gh-ost
Closes #822.
In go-sql-driver/mysql#1075, @acharis notes
that the way the go-sql driver is written, query timeout errors don't
get set in rows.Err() until after a call to rows.Next() is made.
Because this kind of error means there will be no rows in the result
set, the for rows.Next() will never enter the for loop, so we must
check the value of rows.Err() after the loop, and surface the error up
appropriately.
I then went ahead and fixed up the error checking in the two remaining
places we use db.Query, and validated I've covered all cases by
running:
$ golangci-lint run --disable-all -E rowserrcheck
In case this PR introduced Go code changes:
- contributed code is using same conventions as original code
-
script/cibuildreturns with no formatting errors, build errors or unit test errors.