Skip to content

Fix UB while parsing dateTime - #103773

Merged
alexey-milovidov merged 4 commits into
masterfrom
yarik/fix-ub-in-reading-from-datetime
Apr 30, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
yarik/fix-ub-in-reading-from-datetime

Conversation

@yariks5s

@yariks5s yariks5s commented Apr 30, 2026 •

Copy link
Copy Markdown
Member

Trash in results after parsing: https://fiddle.clickhouse.com/5ab07786-bba6-4dce-96b4-5c884e2889ea

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

Fixes undefined behavior while parsing dateTime with a double fractional part.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.194
  • Backported to: 26.4.1.1127, 26.3.10.47, 26.2.17.28, 25.8.24.8

@clickhouse-gh

clickhouse-gh Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [81447ec]

Summary: ✅


AI Review

Summary

This PR fixes an undefined-behavior parsing path for DateTime/DateTime64 inputs with duplicate fractional parts by rejecting the second fractional segment, and adds a regression test for parseDateTime64BestEffortOrNull. The change is small, targeted, and aligned with existing parsing/error semantics; I did not find blocker or major issues.

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 Apr 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 30, 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: 100.00% (12/12) · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov self-assigned this Apr 30, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 30, 2026
@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Apr 30, 2026
Merged via the queue into master with commit 6ac3961 Apr 30, 2026
165 checks passed
@alexey-milovidov
alexey-milovidov deleted the yarik/fix-ub-in-reading-from-datetime branch April 30, 2026 14:33
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Apr 30, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 30, 2026
robot-ch-test-poll1 added a commit that referenced this pull request Apr 30, 2026
Cherry pick #103773 to 25.8: Fix UB while parsing dateTime
robot-ch-test-poll1 added a commit that referenced this pull request Apr 30, 2026
Cherry pick #103773 to 26.1: Fix UB while parsing dateTime
robot-ch-test-poll1 added a commit that referenced this pull request Apr 30, 2026
Cherry pick #103773 to 26.2: Fix UB while parsing dateTime
robot-ch-test-poll1 added a commit that referenced this pull request Apr 30, 2026
Cherry pick #103773 to 26.3: Fix UB while parsing dateTime
robot-ch-test-poll1 added a commit that referenced this pull request Apr 30, 2026
Cherry pick #103773 to 26.4: Fix UB while parsing dateTime
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Apr 30, 2026
alexey-milovidov added a commit that referenced this pull request May 1, 2026
Backport #103773 to 26.4: Fix UB while parsing dateTime
alexey-milovidov added a commit that referenced this pull request May 1, 2026
Backport #103773 to 26.3: Fix UB while parsing dateTime
alexey-milovidov added a commit that referenced this pull request May 1, 2026
Backport #103773 to 26.2: Fix UB while parsing dateTime
pull Bot pushed a commit to TCeason/ClickHouse that referenced this pull request May 6, 2026
Adds expanded coverage (3 inputs * 3 OrNull/OrZero variants) for the
duplicate fractional-separator case in parseDateTime64BestEffort.

The underlying bug is already fixed on master by PR ClickHouse#103773 (yariks5s,
"Fix UB while parsing dateTime", merged 2026-04-30). This test PR
takes over @Avogar's stalled ClickHouse#102890 / closed ClickHouse#103717 by carrying
forward only the additional test cases — the .cpp fix from ClickHouse#102890
is now redundant.

Test cases:
  '12:34:56..123'                                  (double dot directly)
  '12:34:56.123.456'                               (extra dot after fractional)
  '12:34:56.123456789012345678.987654321'          (long fractional + dot)

Each tested against parseDateTime64BestEffort (strict),
parseDateTime64BestEffortOrNull, and parseDateTime64BestEffortOrZero.

Co-authored-by: avogar <[email protected]>
Co-authored-by: Pavel Kruglov <[email protected]>
Co-authored-by: Nihal Z. Miaji <[email protected]>
fm4v added a commit that referenced this pull request May 12, 2026
Backport #103773 to 25.8: Fix UB while parsing dateTime
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…3773

Backport ClickHouse#103773 to 26.4: Fix UB while parsing dateTime
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 Pull request should be backported intentionally. Use this label with great care! 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants