Skip to content
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

Use StringBuilder.GetChunks in MySqlParameter.AppendBinary #977

Closed
bgrainger opened this issue Apr 23, 2021 · 2 comments
Closed

Use StringBuilder.GetChunks in MySqlParameter.AppendBinary #977

bgrainger opened this issue Apr 23, 2021 · 2 comments

Comments

@bgrainger
Copy link
Member

bgrainger commented Apr 23, 2021

If MySqlParameter.Value is set to a StringBuilder instance (#975) and MySqlCommand.Prepare() is called, the code currently calls StringBuilder.ToString() and writes it as a length-encoded UTF-8 string.

In .NET 5.0, it should be more performant to use GetChunks:

  1. loop over the chunks and sum the results of GetByteCount (for a UTF8Encoder) calculate the total length of the UTF-8 string
  2. write the length prefix
  3. loop over the chunks and write each out (encoding each one into UTF-8)
@novak-as
Copy link
Contributor

@bgrainger I can grab this one

bgrainger added a commit that referenced this issue May 26, 2021
- Use StringBuilder.GetChunks for binary parameters
- Fix UTF-8 encoding for surrogate code units split across chunks
bgrainger added a commit that referenced this issue May 27, 2021
- Use StringBuilder.GetChunks for binary parameters
- Fix UTF-8 encoding for surrogate code units split across chunks
bgrainger added a commit that referenced this issue May 27, 2021
- Use StringBuilder.GetChunks for binary parameters
- Fix UTF-8 encoding for surrogate code units split across chunks
bgrainger added a commit that referenced this issue May 27, 2021
- Use StringBuilder.GetChunks for binary parameters
- Fix UTF-8 encoding for surrogate code units split across chunks
@bgrainger
Copy link
Member Author

Fixed in 1.3.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants