-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Add try/catch to cursor.fetchall() #7504
Conversation
I use SQL_QUERY_MUTATOR to add some sql for changing role before the main query. Some of them doesn't return data, and causes exceptions here.
try: | ||
cursor.fetchall() | ||
except BaseException: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I might be missing something obvious here, but why are we calling fetchall()
if we're not even storing the return value anywhere? Wouldn't it be enough to just call exexute()
here and remove the fetch all together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused about here too. We only want data from the last query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah yes, it's explained here: #5517. I think this looks good, but it might be good to add a comment explaining that some engines require calling fetchall()
to force the execute()
calls to execute synchronously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Danielking could you provide more context (as well as a stack trace) as to when this fails. Note in general SQL exceptions should not be swallowed but captured and presented in the explorer as a message to inform the user of the problem.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong and needs more context, we can't swallow all exceptions when fetching.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
I use SQL_QUERY_MUTATOR to add some sql for changing role before the main query. Some of them doesn't return data, and causes exceptions here.
CATEGORY
Choose one
SUMMARY
I use SQL_QUERY_MUTATOR to add some additional queries for changing role before the main query. Some of them doesn't return data, and causes exception here.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
ADDITIONAL INFORMATION
REVIEWERS