Skip to content

skip length validation when casting TEXT to CHAR/VARCHAR to hotfix - #23370

Merged
5 commits merged into
matrixorigin:v3.0.4-hotfixfrom
zhangxu19830126:fix_text_conact
Dec 24, 2025
Merged

5 commits merged into
matrixorigin:v3.0.4-hotfixfrom
zhangxu19830126:fix_text_conact

Conversation

@zhangxu19830126

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #23176

What this PR does / why we need it:

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

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
- Add ALTER ROLE RENAME TO syntax support in parser
- Implement doAlterRole function in frontend to handle role renaming
- Add privilege checks for ALTER ROLE statement
- Add comprehensive e2e tests using DSN connection:
  * Basic rename functionality
  * IF EXISTS handling
  * Error cases (non-existent role, existing role/user name, predefined roles)
  * Multiple sequential renames
  * Role grant persistence after rename verification
- All tests use DSN connection instead of internal SQL executor
@mergify
mergify Bot requested a review from XuPeng-SH December 24, 2025 08:30
@mergify mergify Bot added the kind/bug Something isn't working label Dec 24, 2025
@ghost
ghost merged commit 2a71060 into matrixorigin:v3.0.4-hotfix Dec 24, 2025
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants