Skip to content

test(parser): cover quoted Unicode and client charset bytes - #25879

Merged
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/takeover-25793-unicode-aliases
Jul 22, 2026
Merged

mergify[bot] merged 8 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/takeover-25793-unicode-aliases

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

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 main already 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 latin1 0xE9.

The production scanner changes have therefore been removed. The final diff is deliberately test-only and records the existing compatibility contract:

  • quoted Arabic and Chinese aliases remain accepted;
  • escaped delimiters preserve Unicode contents;
  • raw latin1 bytes remain accepted on both the fast and escaped-delimiter paths;
  • raw client bytes are not reclassified by interpreting them as unconditional UTF-8.

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/mysql
  • go test -race -count=10 -run "Test(QuotedUnicodeIdentifier|QuotedUnicodeIdentifierAliases)$" ./pkg/sql/parsers/dialect/mysql
  • go test -count=1 ./pkg/sql/parsers/...
  • go vet ./pkg/sql/parsers/...
  • git diff --check

@mergify

mergify Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #25793. Mergify cannot evaluate rules on this PR. Once #25793 is merged or closed, Mergify will resume processing this PR. ⚠️

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jul 20, 2026
@VioletQwQ-0 VioletQwQ-0 changed the title fix(parser): support Unicode select aliases fix(parser): validate quoted Unicode identifiers Jul 20, 2026
@VioletQwQ-0
VioletQwQ-0 marked this pull request as ready for review July 20, 2026 04:57
@VioletQwQ-0
VioletQwQ-0 requested a review from XuPeng-SH as a code owner July 20, 2026 04:57
@mergify mergify Bot added the kind/bug Something isn't working label Jul 20, 2026
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added size/S Denotes a PR that changes [10,99] lines and removed size/M Denotes a PR that changes [100,499] lines labels Jul 20, 2026

@XuPeng-SH XuPeng-SH left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@VioletQwQ-0
VioletQwQ-0 requested a review from XuPeng-SH July 22, 2026 05:08
@mergify mergify Bot added kind/test-ci and removed dequeued labels Jul 22, 2026
@matrix-meow matrix-meow added size/S Denotes a PR that changes [10,99] lines and removed size/M Denotes a PR that changes [100,499] lines labels Jul 22, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the queued label Jul 22, 2026
@mergify

mergify Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-22 06:08 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-22 08:04 UTC · at 11101e599de21645dc5cac0d543f460575243ac1 · squash

This pull request spent 1 hour 56 minutes in the queue, including 1 hour 12 minutes 23 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64

@mergify
mergify Bot merged commit b58acd6 into matrixorigin:main Jul 22, 2026
24 of 25 checks passed
@mergify mergify Bot removed the queued label Jul 22, 2026
@VioletQwQ-0
VioletQwQ-0 deleted the codex/takeover-25793-unicode-aliases branch July 22, 2026 08:48

This branch was previously deployed

1 inactive deployment
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 kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants