Repository navigation
fix(column): return error instead of panic on Decimal/BigInt overflow - #1857
Conversation
When inserting values that exceed the range of Decimal128/256 or Int128/UInt128/Int256/UInt256 columns, the driver previously panicked with 'math/big: buffer too small' in bigIntToRaw(), killing the caller goroutine with no way to recover. Changes: - bigIntToRaw now uses deferred recover to catch FillBytes panics and returns a proper error instead - Added explicit signed range check: positive values exceeding 2^(n*8-1)-1 are caught before FillBytes (which treats values as unsigned and won't panic for these) - Decimal32/64 now check for overflow before silent IntPart() truncation - append() in both BigInt and Decimal now propagate errors through Append() and AppendRow() - Added unit tests for all four Decimal sizes and BigInt overflow/valid boundary cases Fixes ClickHouse#1849 Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
SummaryThe PR replaces a Must fix
Should fix
Nits
Verdict
|
- Add negative signed overflow check in bigIntToRaw: values in (-2^n, -2^(n-1)-1] no longer silently encode incorrectly - Remove defer/recover since explicit BitLen guards now catch all overflow cases - Remove unnecessary new(big.Int).Set(v) defensive copy - Fix error message style: lowercase, no colon, consistent with project conventions - Use NewFromString instead of NewFromFloat for exact boundary test values - Add TestBigIntNegativeOverflowReturnsError - Add regression test tests/issues/issue_1849_test.go Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
The regression test called batch.AppendRow which does not exist on the Batch interface (it belongs to BatchColumn), causing a build failure across all CI matrix jobs. Rewrite the test to: - Use batch.Append (the correct Batch method) - Cover both native TCP and HTTP protocols - Cover the database/sql surface via Begin/Prepare/Exec - Test positive and negative overflow for both Decimal128 and Int128
SummaryReplaces a panic ( Should fix
Nits
VerdictRequest changes — small set of fixes (out-of-sync PR description, inconsistent error wrapping across |
…nctions Split the single TestIssue1849 into three independent test functions addressing reviewer feedback from kavirajk: - TestDecimalOverflow: Decimal(38,0) precision overflow, uses decimal.Decimal directly (no any type), named table with single column - TestDecimalSilentDataCorruption: Decimal32/64 IntPart() silent truncation regression, separate sub-tests for each size - TestBigIntOverflow: Int128/UInt128 range overflow and unsigned negative rejection, uses *big.Int directly (no any type) Each test covers all 4 surface combinations (Native TCP, Native HTTP, Std TCP, Std HTTP) with explicit typed table-driven test cases. Variable names use descriptive identifiers (justAboveMaxInt128, justBelowMinInt128) instead of cryptic shorthand. Shared helpers (runDecimalOverflowTest, runBigIntOverflowTest) avoid boilerplate duplication while keeping test cases inline and readable. Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
🤖 Claude reviewReplaces the Verified by trace:
Intentional behavior change worth a release-note line: a negative Key concern (inline): the three integration tests never call Blind spots:
Verdict: ✅ Approve Inline comments are attached to the relevant lines. This summary updates in place on re-review. |
|
Addressed the latest review findings in 4ae5ad6:
The focused native and database/sql regression tests pass over TCP and HTTP locally. The workflow runs are awaiting approval for this fork PR. |
must108
left a comment
There was a problem hiding this comment.
Please address the requested changes by the agent, and also address the failing test cases. Thanks!
|
Updated the branch at
I did not weaken the |
Signed-off-by: must108 <mustaeen18@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: must108 <mustaeen18@gmail.com>
Signed-off-by: must108 <mustaeen18@gmail.com>
fix(column): return errors on Decimal/BigInt overflow
Inserting an out-of-range value into
Decimal32/Decimal64/Decimal128/Decimal256orInt128/UInt128/Int256/UInt256previously could panic inmath/big.FillBytesor silently truncate a scaled decimal coefficient.Changes
Append,AppendRow, and batch APIs without classifying a supported conversion as unsupported.database/sql, over TCP and HTTP, covering decimal overflow/silent-corruption boundaries and signed/unsigned BigInt boundaries.Fixes #1849