Fix charset-aware MySQL expressions and result encoding - #1854
Merged
Merged
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
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.
Follow-up to #1853 (merged before the review fixes could be added).
CHARnumeric rounding/decimal-text truncation and reject invalid byte values.VARCHARfromCONVERT(... USING ...)andCHAR(... USING ...), preserving strict Windows-1252 (latin1) and ASCII conversion rather than disguising text as binary.CONCATand use it for byte-sensitiveLENGTH/HEX; expose expression charset in JDBC metadata. Promote mixed text without losing characters: Unicode wins over non-Unicode at equal coercibility, representable literals retain the expression charset, and ASCII can promote to latin1.character_set_results, advertise the matching wire collation, reject unrepresentable characters, and correctNOT_NULLandCONVERT_TZnullable metadata.Verification on the 172.30.14.10 QA executor after deploying the final candidate:
./gradlew :dingo-calcite:test :dingo-driver:dingo-mysql-service:test :dingo-test:test :dingo-test:compileIntTestJava --console=plain— BUILD SUCCESSFUL. The new mixed-charset regression failed before the fix and passes afterward; the existing latin1+literal regression still passes.€+ utf8mb4🙂yieldsLENGTH=7, HEX=E282ACF09F9982; reversed yieldsF09F9982E282AC; three-operand concat yieldsLENGTH=9, HEX=E282ACF09F9982C2A3. Both ASCII/latin1 orders preserve the euro (8041/4180). Direct result rows decode as€🙂and€Aunder utf8mb4 result collation 45.€🙂,HEX=E282ACF09F9982,Types.VARCHAR.€,é; Connector/J direct and prepared VARCHAR text, nestedLENGTH(CONCAT(...)) = 2, latin1 euroHEX = 80, numericCHAR, invalid ASCII rejection, nullable invalid-zoneCONVERT_TZ, and bothSET NAMES latin1/SET character_set_results=utf8mb4result modes.Additional fix bd854ca (mixed-charset CASE): SQL validation and Rex conversion now preserve Unicode regardless of branch order, including nullable ELSE branches; direct CASE projection metadata reports nullable correctly. QA verification after the change:
./gradlew :dingo-calcite:test --tests io.dingodb.calcite.TestDingoSqlValidator --tests io.dingodb.calcite.TestRex :dingo-test:test --tests io.dingodb.test.QuerySimpleExpressionTest --console=plain— BUILD SUCCESSFUL. Restarted QA executor live MySQL query returnedF09F9982,LENGTH=4, reverse-caseE282AC, and nullable-caseF09F9982.