Repository navigation
fix(util): leave BLOB literal width to the assignment cast like TEXT - #31849
Conversation
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 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? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
🚫 Left the queue24 min in the queue, with no time running CI. So far
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.
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. Merge conditions: 2 of 3 metThis pull request
The batch, tested in place
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
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 aBLOBcolumn failed withERROR 20101 (HY000): internal error: Can't cast 'yyyy…' to BLOB type. Src length 65536 is larger than Dest length 65535. The same value for aTEXTcolumn reportsERROR 1406(data too long) in strict mode, and withsql_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 ignoressql_mode. The runtime assignment cast already enforces the BLOB width in bytes, withER_DATA_TOO_LONG/ truncation depending onsql_mode(that is whatINSERT ... SELECTand multi-byte values already hit).Fix (
eval_expr_util.go+5/-5, comment + one condition): excludeT_blobfrom 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
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/utilpasses.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 withsql_mode = ''. main 15/20, PR 20/20.dtype0 failed,prepare0 failed,dml32 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).