Skip to content

fix(mysql): treat BINARY columns as Blob in Any type mapping#4225

Open
barry3406 wants to merge 1 commit intolaunchbadge:mainfrom
barry3406:fix/mysql-binary-any-type
Open

fix(mysql): treat BINARY columns as Blob in Any type mapping#4225
barry3406 wants to merge 1 commit intolaunchbadge:mainfrom
barry3406:fix/mysql-binary-any-type

Conversation

@barry3406
Copy link
Copy Markdown
Contributor

Fixes #4132

MySQL BINARY(size) columns report ColumnType::String with the BINARY flag set. The Any driver's type conversion checked the column type but not the flags, so BINARY columns got mapped to AnyTypeInfoKind::Text. Reading raw binary data through AnyRow then blew up with a UTF-8 decoding error.

Before:

SELECT * FROM test  -- where `id` is BINARY(16)
-- panics: Utf8Error { valid_up_to: 4, error_len: Some(1) }

After:

-- works: BINARY columns correctly mapped to Blob

The fix checks ColumnFlags::BINARY for String/VarString/VarChar column types and maps to Blob when set.

MySQL BINARY(size) columns report ColumnType::String with the BINARY
flag set. The Any driver type conversion only checked the column type
without looking at flags, so BINARY columns got mapped to
AnyTypeInfoKind::Text instead of Blob. This caused UTF-8 decoding
errors when reading raw binary data through AnyRow.

Check ColumnFlags::BINARY for String/VarString/VarChar column types
and map to Blob when set.

Fixes launchbadge#4132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected treat MySQL BINARY(size) type as String in AnyRow

1 participant