Skip to content

Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER - #104250

Merged
azat merged 4 commits into
ClickHouse:masterfrom
azat:fix-partition-date-overflow
May 23, 2026
Merged

azat merged 4 commits into
ClickHouse:masterfrom
azat:fix-partition-date-overflow

Conversation

@azat

@azat azat commented May 6, 2026 •

Copy link
Copy Markdown
Member

Linked issues

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):

Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER

Fixes: #26263

Version info

  • Merged into: 26.6.1.107
  • Backported to: 26.5.3.17, 26.3.14.18

…te column

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f1d4af0]

Summary: ❌

job_name test_name status info comment
Bugfix validation (functional tests) FAIL
Tests FAIL
Bugfix validation (integration tests) FAIL
test_partition/test.py::test_partition_simple FAIL cidb
test_partition/test.py::test_partition_complex FAIL cidb
test_partition/test.py::test_cannot_attach_active_part FAIL cidb
test_partition/test.py::test_attach_check_all_parts FAIL cidb
test_partition/test.py::test_drop_detached_parts FAIL cidb
test_partition/test.py::test_system_detached_parts FAIL cidb
test_partition/test.py::test_detached_part_dir_exists FAIL cidb
test_partition/test.py::test_make_clone_in_detached FAIL cidb
test_partition/test.py::test_attach_broken_parts FAIL cidb
test_partition/test.py::test_attach_part_path_traversal FAIL cidb
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) FAIL
01710_projection_additional_filters FAIL cidb
03270_processors_profile_log_3 NOT_FAILED cidb
02807_default_date_time_nullable NOT_FAILED cidb
00940_order_by_read_in_order_query_plan NOT_FAILED cidb
02875_merge_engine_set_index NOT_FAILED cidb
02154_default_keyword_insert NOT_FAILED cidb
03325_sqlite_join_wrong_answer NOT_FAILED cidb
00175_partition_by_ignore NOT_FAILED cidb
02707_skip_index_with_in NOT_FAILED cidb
02662_first_last_value NOT_FAILED cidb
56 more test cases not shown
Unit tests (asan_ubsan, function_prop_fuzzer) FAIL
Stress test (arm_tsan) FAIL
Cannot start clickhouse-server FAIL cidb
Check failed FAIL cidb

AI Review

Summary

This PR fixes incorrect handling of out-of-range integer partition literals for Date keys by adding proper range checks for both Field::UInt64 and Field::Int64 conversion paths, and updates regression coverage accordingly. The fix is coherent with the reported failure mode and currently looks correct.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 6, 2026
@azat
azat marked this pull request as draft May 6, 2026 21:31
@azat
azat marked this pull request as ready for review May 7, 2026 12:05
def test_partition_simple(partition_table_simple):
q("ALTER TABLE test.partition_simple DETACH PARTITION 197001")
q("ALTER TABLE test.partition_simple ATTACH PARTITION 197001")
q("ALTER TABLE test.partition_simple DETACH PARTITION '197001'")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bug in the test

@azat
azat force-pushed the fix-partition-date-overflow branch from e42f60e to 159e25a Compare May 7, 2026 17:01
@azat
azat force-pushed the fix-partition-date-overflow branch from 159e25a to dd69428 Compare May 8, 2026 08:21
Comment thread src/Interpreters/convertFieldToType.cpp Resolved
@azat

azat commented May 8, 2026

Copy link
Copy Markdown
Member Author

Bugfix validation (integration tests)

This is expected

@clickhouse-gh

clickhouse-gh Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.60% 76.60% +0.00%

Changed lines: 87.50% (7/8) · Uncovered code

Full report · Diff report

@watson-ch

This comment was marked as low quality.

@azat azat changed the title Fix LOGICAL_ERROR on ALTER PARTITION with out-of-range integer for Date column Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR May 21, 2026
@azat azat changed the title Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER May 21, 2026
@Michicosun Michicosun self-assigned this May 21, 2026
@watson-ch

watson-ch Bot commented May 22, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/ClickHouse/clickhouse-core-incidents/issues/1755

Labels added:

  • v25.12-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@azat
azat enabled auto-merge May 23, 2026 08:06
@azat
azat added this pull request to the merge queue May 23, 2026
Merged via the queue into ClickHouse:master with commit 0175e65 May 23, 2026
159 of 165 checks passed
@azat
azat deleted the fix-partition-date-overflow branch May 23, 2026 08:25
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label May 23, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 23, 2026
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
…rflow

Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
robot-clickhouse-ci-1 added a commit that referenced this pull request Jun 10, 2026
Cherry pick #104250 to 26.3: Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
robot-clickhouse added a commit that referenced this pull request Jun 10, 2026
…r Date instead of silent overflow or LOGICAL_ERROR on ALTER
robot-clickhouse-ci-1 added a commit that referenced this pull request Jun 10, 2026
Cherry pick #104250 to 26.4: Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
robot-clickhouse added a commit that referenced this pull request Jun 10, 2026
…r Date instead of silent overflow or LOGICAL_ERROR on ALTER
robot-clickhouse-ci-1 added a commit that referenced this pull request Jun 10, 2026
Cherry pick #104250 to 26.5: Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
robot-clickhouse added a commit that referenced this pull request Jun 10, 2026
…r Date instead of silent overflow or LOGICAL_ERROR on ALTER
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 10, 2026
alexey-milovidov added a commit that referenced this pull request Jun 11, 2026
Backport #104250 to 26.5: Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
alexey-milovidov added a commit that referenced this pull request Jun 11, 2026
Backport #104250 to 26.3: Reject out-of-range integer partition ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…tion ID for Date instead of silent overflow or LOGICAL_ERROR on ALTER
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
STOR: out-of-range integer partition ID for a Date key in ALTER -> wrong (silent overflow) / exc.
Effect in the production build a394e92: its upstream test(s) 01073_bad_alter_partition fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv).
Upstream patch unchanged, with its test(s): 01073_bad_alter_partition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop partition failed for partition value 2106-02-07

4 participants