-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
table: check valid UTF8 value for UTF8 column #1818
Conversation
We need to check if the input data is valid UTF8 string if the column charset is UTF8, Otherwise, it may cause more serious error in the future, and hard to fix.
Will this PR hurt performance? |
@shenli Yes when we insert or update utf8 column, but that's something we have to pay.
|
LGTM |
@@ -212,6 +213,9 @@ func (t *Table) UpdateRecord(ctx context.Context, h int64, oldData []types.Datum | |||
} | |||
currentData[i] = defaultVal | |||
} | |||
if col.Charset == "utf8" && !utf8.Valid(currentData[i].GetBytes()) { |
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.
Should we also check col.Tp?
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.
Only String types use 'utf8' charset.
@zimulala PTAL |
LGTM |
We need to check if the input data is valid UTF8 string if the column charset is UTF8,
Otherwise, it may cause more serious error in the future, and hard to fix.
This prevents future issue like #1808