Repository navigation
Conversation
The server sends Decimal256(S) as Decimal(76, S), and Decimal(P, S) with P > 38 as is. ColumnDecimal has no 32-byte storage and used 16 bytes per value, so Select() could return wrong values with no error and Insert() hung until the server receive timeout. DecimalType now throws ValidationError for a precision outside 1..38, so CreateColumnByType() and ColumnDecimal reject such types before any data is read or sent. Closes ClickHouse#620
AI review gate — AI review gate could not decide
What to do:
Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically. |
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.
The server sends
Decimal256(S)asDecimal(76, S), and aDecimal(P, S)column with P from 39 to 76 as is, with 32 bytes per value.ColumnDecimalhas no 32-byte storage: it usedColumnInt128for every precision above 18, soSelect()read these columns as 16-byte values (wrong values with no error, or an unrelated protocol error), andInsert()of aColumnDecimal(76, 2)blocked until the server receive timeout.DecimalTypenow throwsValidationErrorfor a precision outside 1..38 (this replaces theTODO: assert(precision <= 38 && precision > 0)).CreateColumnByType(),Select()andColumnDecimalreject such types before they read or send data, also insideNullable,Arrayand so on. RealDecimal256support stays in #377.Tests:
TypesCase.DecimalPrecisionOutOfRangeinut/types_ut.cpp: 0, 39 and 76 throw; 1 and 38 do not.CreateColumnByType.DecimalPrecisionOverLimitinut/CreateColumnByType_ut.cpp:Decimal(39, 2),Decimal(76, 2), also inNullableandArray.ClientCase.SelectDecimal256Throwsinut/client_ut.cpp:SELECT toDecimal256(number + 1, 2)throwsValidationError. Before the change it threwUnimplementedError: unimplemented 72(no compression) orCompressionError(LZ4).The new tests fail without the change. The whole
clickhouse-cpp-utsuite passes against a local server (1078 tests).Fixes #620
Note
Medium Risk
Changes decimal type handling on the read/write path, but only rejects previously broken precisions 39–76; supported decimals 1–38 are unchanged.
Overview
Fails fast on unsupported high-precision decimals instead of mis-reading 32-byte
Decimal256/Decimal(76, …)wire data as 16-byte values or hanging on insert.DecimalTypenow throwsValidationErrorwhen precision is not in 1..38 (replacing a TODO assert), which blocks unsupported decimals at type/column creation—including nestedNullable/Array—beforeSelect()orCreateColumnByType()touch protocol data.Tests cover
Type::CreateDecimal, column factory parsing, and a liveSELECT toDecimal256(...)expectingValidationError.Reviewed by Cursor Bugbot for commit 53dd55e. Bugbot is set up for automated code reviews on this repo. Configure here.