Cancel results for user automatically#563
Closed
andyundso wants to merge 3 commits intorails-sqlserver:masterfrom
Closed
Cancel results for user automatically#563andyundso wants to merge 3 commits intorails-sqlserver:masterfrom
andyundso wants to merge 3 commits intorails-sqlserver:masterfrom
Conversation
do, insert and eachdc5083a to
30f0541
Compare
Member
Author
|
@aharpervc even if I am still waiting for a reply on the original issue, I think this PR is good to have look. |
2df5f18 to
94c728f
Compare
94c728f to
d331213
Compare
Member
Author
|
Replaced with #595. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #539
FreeTDS enforces a strict sequence of how queries are sent and results are retrieved. To summarize it very briefly:
dbopen.dbcmd.dbsqlsend.dbsqlok.dbdbresults.dbnextrowor cancel the running results (dbcancel)dbcloseif not cancelled.You do not have to serialize / bind each retrieved result, but you still need to fetch them. This is mentioned in the sample code as well:
The current implementation of
doandinsertperform the entire sequence. However,eachworks different: Sinceeachlazy-loads each result from the server, it cannot perform the entire sequence as we do not want to fetch all results at once and the user is free to cancel the iterator early.As mentioned on #539, the error
Assertion conn->in_net_tds == NULL'likely occured when people did not callcancelon the result object, as the query is technically still pending from FreeTDS point-of-view.FreeTDS also mentions:
With this PR, in
#execute, I check if we have to still acknowledge and fetch results prior to running another query, essentially doing the job ofcancelautomatically for the user.This is not my initially proposed solution on #539. I have coded out that proposed solution as well in a different branch, but during that development, I imagined that people could run into issues when a query will produce a large result set. But it helped me to understand the request lifecycle of FreeTDS better in order to develop this solution.