Skip to content

Fix logical error in parseDateTime with non-ASCII input bytes - #106856

Merged
nikitamikhaylov merged 1 commit into
masterfrom
fix-parse-datetime-non-ascii-length-error
Jun 15, 2026
Merged

nikitamikhaylov merged 1 commit into
masterfrom
fix-parse-datetime-non-ascii-length-error

Conversation

@Avogar

@Avogar Avogar commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

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 logical error in parseDateTime with non-ASCII input bytes.

Version info

  • Merged into: 26.6.1.812

`String(expected, 1)` and `String(*cur, 1)` in error messages inside
`assertChar` and `assertNumber` resolved to `std::string(size_t count, char ch)`
with the char value as the count. When the char had its high bit set (e.g. `\x82`
= -126 signed), the implicit conversion to `size_t` wrapped to ~2^64, causing
`std::length_error` which surfaced as a logical error.

Fix by swapping arguments to `String(1, ch)` so the count is always 1.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1d78978]

Summary: ❌

job_name test_name status info comment
Bugfix validation (functional tests) FAIL
04324_parse_datetime_non_ascii FAIL cidb IGNORED

AI Review

Summary

This PR fixes parseDateTime error reporting for non-ASCII bytes by constructing one-byte String values with the (size, char) constructor order in assertChar and assertNumber. The change matches the stated Bug Fix contract, the remaining suspicious String(..., 1) uses in the touched parser are pointer-length constructions, and the new stateless test covers the non-ASCII input/format failure paths. No findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.60% 84.60% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.20% 77.20% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 11/13 (84.62%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@groeneai groeneai mentioned this pull request Jun 11, 2026
@Algunenano Algunenano self-assigned this Jun 12, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I did not find any similar issues in the code. We could avoid using String here and just give the hex code or similar (since most of the time it will be something not printable) but not needed

@clickhouse-gh

clickhouse-gh Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR is a one-line correctness fix: it corrects the argument order of a String(count, char) construction inside parseDateTime's parse-failure error message, plus adds a regression test. That code only runs when parseDateTime hits a malformed input and throws, so it cannot affect the execution path of the four flagged queries (ClickBench Q22/Q23, TPC-H Q7/Q20), none of which call parseDateTime. All four flagged improvements have been downgraded to not-sure as run-to-run variance rather than real PR effects; Q22 and Q20 in particular had noisy underlying measurements. No action needed on the perf deltas.

clickbench

⚠️ 2 inconclusive

Flagged queries (2 of 43)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
⚠️ 22 not_sure 334 263 -21.3% <0.0001 PR only fixes a String() arg-order bug in parseDateTime's error path; Q22 never executes it. -21% with very noisy sample
⚠️ 23 not_sure 297 201 -32.3% <0.0001 parseDateTime exception-path fix cannot touch this SELECT's hot path; the -32% is off-path, not a real PR effect.

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
⚠️ 7 not_sure 113 72 -36.3% <0.0001 TPC-H Q7 does not call parseDateTime; the changed error-message code is unreachable here. -36% is run-to-run variance.
⚠️ 20 not_sure 248 128 -48.4% <0.0001 Noisy query, and the parseDateTime fix is off this query's path. -48% with high variance is not a PR effect.

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 7250641b-a6f2-40e0-bbed-44db47697110
  • MIRAI run: 2e91cafc-1816-4c0d-b7d8-3157bb7345f3
  • PR check IDs:
    • clickbench_375065_1781272675
    • clickbench_375079_1781272675
    • clickbench_375085_1781272675
    • tpch_adapted_1_official_375091_1781272675
    • tpch_adapted_1_official_375098_1781272675
    • tpch_adapted_1_official_375111_1781272675

@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Jun 15, 2026
Merged via the queue into master with commit 74cef71 Jun 15, 2026
164 of 166 checks passed
@nikitamikhaylov
nikitamikhaylov deleted the fix-parse-datetime-non-ascii-length-error branch June 15, 2026 11:49
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

4 participants