Fix Int32 exponent overflow in SAMPLE ratio parser#109197
Merged
Algunenano merged 2 commits intoJul 7, 2026
Merged
Conversation
Contributor
|
Workflow [PR], commit [a54fce5] Summary: ✅
AI ReviewSummaryThis PR fixes Missing context / blind spots
Final Verdict✅ No remaining blockers or majors from this review. |
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 37/38 (97.37%) · Uncovered code |
Merged
via the queue into
ClickHouse:master
with commit Jul 7, 2026
28092a4
344 of 345 checks passed
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.
Closes: #103517
ParserSampleRatioread the exponent of aSAMPLEratio into anInt32using the pointer-returningtryReadIntText, which discards the overflow result. On overflow the exponent was left at0while the position still advanced, so the only check (whether characters were consumed) passed and a huge or tiny exponent silently became1e0. For exampleSELECT count() FROM t SAMPLE 1e-3000000000sampled 100% of the data instead of ~0 rows.The exponent is now read via a helper that saturates the magnitude through the existing
readUInt128Textpath, so any exponent magnitude (not just theInt32/Int64range) is handled correctly.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
SAMPLEratios with an exponent whose magnitude overflowsInt32(e.g.SAMPLE 1e-3000000000) being silently treated asSAMPLE 1.Version info
26.7.1.591(included in26.7and later)