Repository navigation
Conversation
…ectly MySQL transmits DECIMAL/NEWDECIMAL as ASCII text even over the binary protocol, but `int_decode`/`uint_decode` reinterpreted those bytes as a little-endian integer. Decoding e.g. `SUM(int_col)` into `u64` via an explicit type override or `try_get_unchecked` silently produced garbage (the bytes `b"13"` were read as `0x3331` = 13105 instead of 13). Parse the textual value for DECIMAL/NEWDECIMAL columns and require it to be integral: integral values decode correctly, while fractional values now return a clean error instead of a corrupted result. The `Type::compatible` gate is intentionally left unchanged, so macro type inference still resolves DECIMAL columns to `Decimal`/`BigDecimal`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Map130
marked this pull request as draft
September 24, 2026 19:42
Map130
marked this pull request as ready for review
September 24, 2026 19:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Decoding a MySQL DECIMAL/NEWDECIMAL column into an integer type silently
corrupted the value. MySQL sends DECIMAL as ASCII text even in the binary
protocol, but the integer decoders read those bytes as a little-endian
integer, so decoding e.g.
SUM(int_col)intou64via an explicit typeoverride or
try_get_uncheckedproduced garbage: the bytesb"13"(
0x31 0x33) decoded to0x3331= 13105 instead of 13.Fix
int_decode/uint_decodenow detect DECIMAL/NEWDECIMAL columns and parsethe textual value, requiring it to be integral:
has a fractional parterror instead of asilently corrupted result;
Type::compatibleis deliberately left unchanged, so macro inference stillmaps DECIMAL columns to
Decimal/BigDecimaland does not lossily inferu64forSUM().Tests
Added
decode_integer_from_decimalintests/mysql/types.rscovering thecorrect-value, fractional-error, and negative cases. Verified against a
live MySQL 8.0 with and without the
rust_decimal/bigdecimalfeatures;existing
mysql-typesandmysql-macrossuites pass.