-
Notifications
You must be signed in to change notification settings - Fork 206
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
edit: datum struct string type added utf8 check #1488
base: main
Are you sure you want to change the base?
Conversation
I forgot, I'll try adding a few more unit tests later |
@@ -765,6 +776,11 @@ impl Datum { | |||
} | |||
} | |||
|
|||
fn valid_is_utf8(s: &str) -> Result<()> { |
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.
This check may be expensive for long string, better to add an option to decide whether to do this check.
@@ -765,6 +776,11 @@ impl Datum { | |||
} | |||
} | |||
|
|||
fn valid_is_utf8(s: &str) -> Result<()> { | |||
from_utf8(s.as_bytes()).context(InvalidStringEncoding { msg: s })?; |
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.
IMO this function should return bool
, not a result.
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.
ok
I checked the rust official documentation, and for the way to build Datum objects from String in datum.rs, rust guarantees that String is a utf8 string, which I might need to modify elsewhere. 😢 |
Yes, I grep the code and find several place contains As for debugging this issue, you can construct a GBK string using SDK, and trace why there is no error for it. |
Ok, I'll try |
The |
Rationale
Close #1300
Detailed Changes
Check whether it is a utf8 string when inserting data
Test Plan
pass