Repository navigation
fix cast - #25340
fix cast#25340
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
I found a real blocker here.
The new truncateCastBytesResult(...) hook now runs inside the shared ...ToStr helpers that are used by both plain cast and internal cast_strict.
That means assignment-only cast_strict into real CHAR/VARCHAR(N) columns will now silently truncate many non-string source types before the old width-check/error path runs.
For example, numeric / decimal / date / datetime / timestamp / time assignments into CHAR/VARCHAR targets now go through helpers like signedToStr, unsignedToStr, floatToStr, dateToStr, datetimeToStr, timestampToStr, timeToStr, decimal64ToStr, decimal128ToStr, decimal256ToStr, and all of them call truncateCastBytesResult(result, toType) before the final over-width check.
But cast_strict is explicitly the assignment path that is supposed to reject over-width writes instead of truncating them. So a statement that should fail with data-too-long semantics can now silently store a shortened string.
Suggested fix:
- thread strict/lenient behavior into the shared
...ToStrhelpers, or - split truncation so only plain
casttruncates whilecast_strictstill errors.
There is also still an incompleteness issue for other supported -> CHAR/VARCHAR paths (YEAR/UUID/JSON/ENUM/BIT are not all aligned with the new truncation behavior), but the cast_strict regression above is the blocker.
已经修改了. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewing the latest head: the earlier primary blocker is fixed now.
- The old concern that
cast_strictwas silently truncating non-string assignments intoCHAR/VARCHARis now addressed. The current head threads strict/lenient width handling through the affected numeric/date/time/decimal...ToStrhelpers, and the new strict-path regression tests cover representative non-string cases.
What remains is a narrower consistency gap around some other -> CHAR/VARCHAR cast paths, especially YEAR -> CHAR/VARCHAR. But I checked the target-branch baseline, and that YEAR path was already behaving this way before this PR; it is not a new regression introduced by this change.
So for this PR itself, I no longer see a substantive blocker. The remaining cast-matrix consistency cleanup looks like follow-up work rather than a reason to block this fix.
LGTM.
Merge Queue Status
This pull request spent 24 minutes 55 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 2 hours 52 minutes 11 seconds in the queue, including 1 hour 15 minutes 51 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #25225
#25250
#25249
What this PR does / why we need it:
修改 :
cast('+0012' as unsigned)修改 :
cast(' +7e0' as double),修改:
select cast(12345 as char(3)), length(cast(12345 as char(3)));