Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database/sql: Improper error handling. #29975

Closed
SagarPuneria opened this issue Jan 29, 2019 · 7 comments
Closed

database/sql: Improper error handling. #29975

SagarPuneria opened this issue Jan 29, 2019 · 7 comments

Comments

@SagarPuneria
Copy link

@SagarPuneria SagarPuneria commented Jan 29, 2019

#29973

if rs.lasterr != nil {

I think it would be better to refactor error handling code something like this:
if err := rs.lasterr; err != nil && err != io.EOF {

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 29, 2019

Can you explain why it is necessary to check io.EOF there?

CC @kardianos

@ianlancetaylor ianlancetaylor added this to the Go1.13 milestone Jan 29, 2019
@SagarPuneria
Copy link
Author

@SagarPuneria SagarPuneria commented Jan 30, 2019

For more information read documentation for type RowsNextResultSet interface and it is clearly mentioned that NextResultSet should return io.EOF when there are no more result sets.

@kardianos
Copy link
Contributor

@kardianos kardianos commented Jan 30, 2019

Please look at https://bitbucket.org/kardianos/table for the proper way to use NextResultSet. I'm aware of how to use it and the documentation; I wrote it.

@kardianos kardianos closed this Jan 30, 2019
@SagarPuneria
Copy link
Author

@SagarPuneria SagarPuneria commented Jan 31, 2019

@kardianos, let me clear, i am new to database.

The reason behind escalating this issue is that i want to know in which case NextResultSet return true?

I tried all the cases using mysql database it is always returning false. If so then what is the use case of implementing NextResultSet?
Could you please give me at least one use case where NextResultSet return true.

Before giving your answer, i would suggest you to do sample program on NextResultSet where it can return true case.

I hope you got my Question.

@agnivade
Copy link
Contributor

@agnivade agnivade commented Jan 31, 2019

If you are new to databases and want some clarifications, please take a look at the Questions wiki page to ask questions like these. You will get better and faster answers there. The issue tracker is primarily for bugs and proposals.

@SagarPuneria
Copy link
Author

@SagarPuneria SagarPuneria commented Jan 31, 2019

@agnivade, I understand your concern. I tried all the cases using mysql database, NextResultSet is always returning false. If so then it is bug right. So i am in right page for escalating this as an issue.

@SagarPuneria
Copy link
Author

@SagarPuneria SagarPuneria commented Feb 2, 2019

Its was my big mistake. There is NO issue in NextResultSet method.

I was working with different databases using golang sql package.
In PostgreSQL this NextResultSet method returns true using (github.com/lib/pq) even there is no multiple resultsets.
Sample program

I was thinking this same behavior with MySQL using (github.com/go-sql-driver/mysql)

Eventually i found unexpected behavior (or bug) of lib/pq

I filed an issue report on lib/pq.

@golang golang locked and limited conversation to collaborators Feb 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.