*: introduce new API ParseWithParams (#22499)#22549
Merged
ti-srebot merged 2 commits intopingcap:release-3.0from Feb 20, 2021
Merged
*: introduce new API ParseWithParams (#22499)#22549ti-srebot merged 2 commits intopingcap:release-3.0from
ti-srebot merged 2 commits intopingcap:release-3.0from
Conversation
Contributor
Author
|
/run-all-tests |
Contributor
Author
|
@xhebox you're already a collaborator in bot's repo. |
Signed-off-by: xhe <xw897002528@gmail.com>
eab6549 to
54a0d46
Compare
Signed-off-by: xhe <xw897002528@gmail.com>
Contributor
|
LGTM |
Member
|
/run-all-tests |
bb7133
approved these changes
Feb 20, 2021
Member
|
/merge |
Contributor
Author
|
/run-all-tests |
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.
cherry-pick #22499 to release-3.0
You can switch your code base to this Pull Request by using git-extras:
# In tidb repo: git pr https://github.com/pingcap/tidb/pull/22549After apply modifications, you can push your change to this PR via:
What problem does this PR solve?
Problem Summary: This PR adds a new API
ParseWithParamsto help process unsafe arguments than justfmt.Sprintf. Also a helper APIExecuteInternalthat is usingParseWithParamsandExecuteStmt.I did not use
PrepareStmtsince it is not possible to use placeholder likeselect * from t where c in ?. But we do have such requirement.ExecuteInternalis redefined to useParseWithParamsand always use utf8 charset for safety. But it is still needed to modify cases likeExecuteInternal(fmt.Sprintf(...)).ExecRestrictedSQLis too large, thus it is both annoying and duplicated to write a newRestrictedSQLExecutorbased onParseWithParams. From the git history, this is a very legacy API that is 4 or 5 years old. It should be removed/refactored in further works. So the current plan is, write likeExecRestrictedSQL(session.EscapeSQL(sql, args...)). And it will goes to the modifiedExecuteInternaleventually to use utf8 charset to prevent attacks based on charsets.Check List
Tests
Release note