server: return error for new statement after opening cursor #40095
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.
Signed-off-by: YangKeao yangkeao@chunibyo.icu
What problem does this PR solve?
Issue Number: close #40094, close #39148, close #38116
Problem Summary:
Run statement after opening a cursor will make the sate (session variable, etc) hard to predict. The current implementation of cursor fetch in TiDB doesn't allow creating multiple cursor at the same time.
What is changed and how it works?
This PR add a check to return error when the command other than fetching/closing the active cursor arrives. The user will have to close the existing statement before running another commands.
The user forgot to close the statement may fail to run existing program ()
Check List
Tests
Side effects
If the user forgot to close the statement explicitly before running other queries, the program will not continue to work with this patch. However, the former behavior is both unsafe (can cause panic in TiDB) and unpredictable (can read unpredictable data).
Release note