Skip to content

database/sql: Improper error handling. #29975

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

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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@SagarPuneria
Copy link

#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
Member

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

CC @kardianos

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 29, 2019
@ianlancetaylor ianlancetaylor added this to the Go1.13 milestone Jan 29, 2019
@SagarPuneria
Copy link
Author

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

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.

@SagarPuneria
Copy link
Author

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

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 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

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.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants