Skip to content

Reject unsigned rounding scales above the Int16 range instead of reading them as negative - #132299

Merged
Blargian merged 2 commits into
ClickHouse:masterfrom
lazerg:fix/issue-132276-round-unsigned-scale
Nov 17, 2026
Merged

Blargian merged 2 commits into
ClickHouse:masterfrom
lazerg:fix/issue-132276-round-unsigned-scale

Conversation

@lazerg

@lazerg lazerg commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #132276

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix round, floor, ceil, trunc and roundBankers treating a UInt64 scale close to 2^64 as a negative scale. Such scales now throw ARGUMENT_OUT_OF_BOUND like any other scale outside the Int16 range.

Description

The scale was cast to Int64 before the range check, so 18446744073709551614 became -2 and passed it, and round(1234.5678, 18446744073709551614) returned 1200. The check now compares the scale in its own type, for both constant and non-constant scales. The new test fails on master.


Workflow [PR]
Sync PR [sync-upstream/pr/132299]

Version info

  • Merged into: 26.11.1.2616-master (included in 26.11 and later)

@PedroTadim PedroTadim self-assigned this Nov 17, 2026
@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Nov 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1d4f8ec]

Summary: ✅


AI Review

Summary

PR #132299, reviewed at 1d4f8ec0b12bc23b56bf0bee0f96d5ece2a23036, validates rounding scales in their original integer type before narrowing to Int16, preventing oversized UInt64 scales from being interpreted as negative. No remaining findings. The earlier coverage finding is addressed by the numeric and decimal cases with non-constant values and constant scales, and its thread has been resolved. The regression test passes in Fast test for this commit.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Nov 17, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... label Nov 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1d4f8ec0b with master d271656aa (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

4 object files changed (-35.72 KiB total), 0 added.

Object file Master PR Δ
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsRound.cpp.o 8.72 MiB 8.69 MiB -35.72 KiB (-0.40%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

10 translation units recompiled, 73 s compile time in total, 10 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost -5.0 s (-6%) in total before that adjustment.

Job report

@PedroTadim
PedroTadim added this pull request to the merge queue Nov 17, 2026
@Blargian
Blargian removed this pull request from the merge queue due to a manual request Nov 17, 2026
@Blargian
Blargian added this pull request to the merge queue Nov 17, 2026
Merged via the queue into ClickHouse:master with commit 49e44ae Nov 17, 2026
193 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... external Author is not a member of the ClickHouse organization pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

4 participants