*: introduce new API ParseWithParams#22499
Conversation
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
|
LGTM |
| buf[pos] = '\\' | ||
| buf[pos+1] = '\\' | ||
| pos += 2 | ||
| default: |
There was a problem hiding this comment.
I think \t should be OK. It is just another type of whitespace. And the original port did not include that, either.
There was a problem hiding this comment.
In the MySQL document, there is a "Table 9.1 Special Character Escape Sequences"
https://dev.mysql.com/doc/refman/8.0/en/string-literals.html
I'm not sure are they the same things.
There was a problem hiding this comment.
I think that is the reverse of escaping. The table means that mysql will interpret \t as 0x09 in string datum. And it only takes effect if NO_BACKSLASH_ESCAPES is off.
Here what we want is, disallow the parser/lexer treating any character in the string as any special term/token.
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
|
/label needs-cherry-pick-3.0 |
|
/run-cherry-pick |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
|
cherry pick to release-5.0-rc in PR #22547 |
|
cherry pick to release-4.0 in PR #22548 |
|
cherry pick to release-3.1 failed |
|
cherry pick to release-3.0 in PR #22549 |
|
/label needs-cherry-pick-2.1 |
|
These labels are not found |
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
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