Repository navigation
test(parser): cover quoted Unicode and client charset bytes - #25879
mergify[bot] merged 8 commits into
Conversation
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? |
There was a problem hiding this comment.
Requesting changes for one correctness regression. scanLiteralIdentifier is also used for backtick-quoted user-variable names after @. User variables are not schema identifiers, so the new BMP-only predicate changes pre-existing valid parser behavior: clean base accepts SELECT @`😀`, while this head returns a syntax error. MySQL documents that quoted user-variable names may contain otherwise-unavailable characters, and its lexer consumes that branch using the client multibyte character set rather than applying the schema-identifier BMP restriction. Please make validation context-aware: schema/object/alias identifiers may reject invalid UTF-8, NUL, and code points above U+FFFF, but quoted user variables must preserve valid utf8mb4 names while still rejecting malformed input as appropriate. Add regressions for SELECT @`😀` and the escaped-delimiter slow path. The rest of the review is clean: build, vet, full parser tests, and race tests pass; the validator adds no allocations and there are no resource/lifecycle risks. Also note that the exact quoted Arabic/Chinese cases from #25014 already pass on the clean base, so the actual delta here is validation hardening rather than enabling those valid cases.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
The shared validation introduces a parser compatibility regression for quoted user variables.
P1 - Do not apply the BMP restriction to quoted user variables (pkg/sql/parsers/dialect/mysql/scanner.go:580)
Scan routes @ followed by a backtick through scanLiteralIdentifier, then emits AT_ID; the grammar accepts that as a user variable. On origin/main, SELECT @😀`` was accepted because quoted contents were returned unchanged. This change rejects it via r > '\uFFFF', producing a syntax error. Escaped-backtick names use the same validator. Apply the restriction only to schema/object identifiers and add fast- and slow-path user-variable regressions.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 62735e7. The prior client-character-set blocker is resolved by removing the parser-side UTF-8/BMP production changes; the final diff is test-only and accurately preserves the current raw COM_QUERY byte contract across Arabic/Chinese aliases, escaped delimiters, latin1 bytes, and byte sequences that must not be reclassified before charset normalization. No blocking correctness, compatibility, lifecycle, or coverage issues found. Full parser tests, focused race tests x10, go vet, and git diff --check passed; GitHub CI is green.
Merge Queue Status
This pull request spent 1 hour 56 minutes in the queue, including 1 hour 12 minutes 23 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR relates to:
issue #25014
What this PR does / why we need it:
This PR continues the unfinished work from #25793 while preserving its original commits and authorship.
Review established that current
mainalready accepts the quoted Arabic and Chinese aliases reported in #25014. It also established that the parser receives raw COM_QUERY bytes without the negotiated client character set, so enforcing UTF-8/BMP rules inside the scanner would reject valid non-UTF-8 client input such as latin10xE9.The production scanner changes have therefore been removed. The final diff is deliberately test-only and records the existing compatibility contract:
Character-set-aware identifier validation must happen after a future COM_QUERY normalization boundary has decoded
character_set_client; this PR does not introduce that broader protocol change.Validation
go test -count=1 -run "Test(QuotedUnicodeIdentifier|QuotedUnicodeIdentifierAliases)$" ./pkg/sql/parsers/dialect/mysqlgo test -race -count=10 -run "Test(QuotedUnicodeIdentifier|QuotedUnicodeIdentifierAliases)$" ./pkg/sql/parsers/dialect/mysqlgo test -count=1 ./pkg/sql/parsers/...go vet ./pkg/sql/parsers/...git diff --check