Skip to content

fix(util): leave BLOB literal width to the assignment cast like TEXT - #31849

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix-31808-blob-literal-width
Oct 30, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix-31808-blob-literal-width

Conversation

@MatrixAdventurer

@MatrixAdventurer MatrixAdventurer commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Ref #31808 (the BLOB part: "BLOB shares the same boundary failure")

What this PR does / why we need it:

INSERT INTO t(b) VALUES ('<65536 bytes>') into a BLOB column failed with ERROR 20101 (HY000): internal error: Can't cast 'yyyy…' to BLOB type. Src length 65536 is larger than Dest length 65535. The same value for a TEXT column reports ERROR 1406 (data too long) in strict mode, and with sql_mode = '' TEXT is truncated with warning 1265 while BLOB still failed with the internal error.

Cause: SetInsertValueString (INSERT VALUES literal fast path) checks the width at plan time for every string type except CHAR/VARCHAR/TEXT/DATALINK. For BLOB that check counts runes (not bytes), returns an internal error and ignores sql_mode. The runtime assignment cast already enforces the BLOB width in bytes, with ER_DATA_TOO_LONG / truncation depending on sql_mode (that is what INSERT ... SELECT and multi-byte values already hit).

Fix (eval_expr_util.go +5/-5, comment + one condition): exclude T_blob from the plan-time check, like TEXT.

The TEXT message wording discussed in #31808 ("Can't cast column from TEXT type to TEXT type …") is the generic width message shared with CHAR/VARCHAR and is not changed here.

Tests

  • New UT TestSetInsertValueStringDefersBlobWidthToAssignmentCast (pkg/sql/util): an oversized BLOB/TEXT literal is passed through to the assignment cast. RED on main (BLOB returns the internal error), GREEN here. go test ./pkg/sql/util passes.
  • New BVT dtype/blob_literal_width.sql: 65535-byte BLOB accepted; 65536-byte BLOB and TEXT literals both report data truncation (1406) in strict mode and are truncated to 65535 with sql_mode = ''. main 15/20, PR 20/20.
  • BVT dirs PR vs main: dtype 0 failed, prepare 0 failed, dml 32 failed both (same files, local env).

Merge Danger

Low. Only oversized BLOB literals change: from internal error 20101 to the TEXT behavior (1406 in strict mode, truncation with a warning otherwise).

本操作由 LW 授权的 Grok Bot 智能体执行。

An INSERT VALUES string literal longer than a BLOB column was rejected at plan
time with ERROR 20101 internal error (counting runes, ignoring sql_mode), while
the same value for TEXT reports ER_DATA_TOO_LONG (1406) in strict mode and is
truncated with a warning when sql_mode is empty. Exclude BLOB from the
plan-time check, as CHAR/VARCHAR/TEXT already are, so the runtime assignment
cast enforces the byte width and honors sql_mode.

Ref matrixorigin#31808
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 65ba6d21f60cc52597665d38354c839b985cf7b8

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: 65ba6d21f60cc52597665d38354c839b985cf7b8

Assessment: approve

The BLOB literal fix correctly delegates byte limits and SQL-mode handling to existing assignment casts. Both planner paths retain enforcement. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Passed 10 focused tests across util, function, and plan; passed all 40 owning util-package tests without skips.

  • Isolation preflight, matching native prerequisite build, and changed-file formatting checks passed.

  • Reused frozen-head successful build, UT, SCA, and both active BVT-group conclusions.

  • Receipts and retained logs reconciled in validation-audit.json; discussion-assessment.json covers both discussion keys. Source remains unchanged.

Limitations:

  • No local service BVT run; individual CI case logs and raw author validation artifacts were unavailable.

  • The broader TEXT diagnostic wording concern remains outside this PR's scoped BLOB fix.

@mergify mergify Bot added the queued label Oct 30, 2026
@mergify

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

24 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 30 Oct, 12:41 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 13:05 · 35263a9

Reason

Pull request #31849 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit e6deef8 into matrixorigin:main Oct 30, 2026
20 of 22 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 30, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants