-
Notifications
You must be signed in to change notification settings - Fork 284
fix: skip length validation when casting TEXT to CHAR/VARCHAR #23177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zhangxu19830126
wants to merge
3
commits into
matrixorigin:main
Choose a base branch
from
zhangxu19830126:fix_conact
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+180
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem: When updating TEXT columns with CONCAT operations in UPDATE statements, the system throws an error: 'Can't cast column from TEXT type to CHAR type because of one or more values in that column. Src length 260 is larger than Dest length 255'. Root Cause: The strToStr function was performing length validation for all string type casts, including when casting from TEXT (which has no length limit) to CHAR/VARCHAR types. This caused errors when TEXT values exceeded the target type's length limit, even though TEXT should be allowed to store strings of any length. Solution: - Added source type check in strToStr function to detect when source is TEXT - Skip length validation when casting from TEXT to CHAR/VARCHAR types - This allows TEXT columns to be updated with CONCAT operations that may exceed CHAR/VARCHAR length limits - The storage layer will handle the actual type correctly Changes: - Modified strToStr() in func_cast.go to skip length check for TEXT source - Added comprehensive unit tests in func_cast_test.go covering: * TEXT to CHAR conversions with length exceeding target limit * TEXT to VARCHAR conversions with length exceeding target limit * NULL value handling * Multiple values scenarios * Verification that non-TEXT types still perform length validation Test: Test_strToStr_TextToCharVarchar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
When updating TEXT columns with CONCAT operations in UPDATE statements, the system throws an error: 'Can't cast column from TEXT type to CHAR type because of one or more values in that column. Src length 260 is larger than Dest length 255'.
Root Cause:
The strToStr function was performing length validation for all string type casts, including when casting from TEXT (which has no length limit) to CHAR/VARCHAR types. This caused errors when TEXT values exceeded the target type's length limit, even though TEXT should be allowed to store strings of any length.
Solution:
Changes:
Test: Test_strToStr_TextToCharVarchar
What type of PR is this?
Which issue(s) this PR fixes:
issue #23176
What this PR does / why we need it:
Fix bug.