Skip to content

fix: honor mysql ignore space for built-in functions - #28677

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
iamlinjunhong:m-28603
Sep 14, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
iamlinjunhong:m-28603

Conversation

@iamlinjunhong

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 #28603

What this PR does / why we need it:

fix: honor mysql ignore space for built-in functions

@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 →

@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 31bcca6 against base 7013fbb. Two concrete issues remain: generic TRIM calls now reach a native-only formatter and panic before binding; and IGNORE_SPACE does not enforce the documented reserved-name behavior. Details inline.

Reviewed the lexer lookahead/function allowlist, grammar and generated semantic change, AST/binder consumers, session cache invalidation, saved-mode prepared/view paths, internal SHOW ACCOUNT SQL adjustment and UT/BVT oracles. The intended whitespace-sensitive builtin-vs-UDF distinction, unaffected ABS/MOD controls and session-local mode flag are otherwise scoped. No new runtime wire opcode, asynchronous ownership or per-row allocation path is introduced. The lexer adds lookahead on sensitive names; tests currently focus function calls and omit the two failing contracts below.

Evidence is source-derived, with MySQL's official function-name parsing contract checked; no fresh native UT, live SQL or performance run is claimed. CI was not awaited and live head/base were rechecked before posting.

@aptend aptend 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.

Deep review completed on exact head 31bcca6ad3531a8be9ccff92b4fb2d6f94fa4442 against exact base 7013fbbd6e152ba31da2d3dbba7012ac7f8b8462. I read the complete existing review/comment history and both current unresolved threads, then independently audited the full diff and reproduced both blocking contracts below.

The function allowlist matches MySQL's documented whitespace-sensitive set, parser-mode propagation/cache invalidation and saved-mode prepared/view behavior are otherwise coherent. No lifecycle, concurrency, wire-version, or unbounded-allocation risk was introduced.

Validation:

  • full pkg/sql/parsers/dialect/mysql tests passed
  • focused IGNORE_SPACE parser tests passed under -race
  • focused planner and frontend/cache tests passed
  • parser regeneration was deterministic; git diff --check passed
  • review-only counterexample tests reproduced the formatter panic, semantic round-trip loss, and identifier-reservation failures; those tests were removed afterward

The two inline findings are blocking, so I am requesting changes.

Comment thread pkg/sql/parsers/tree/expr.go Resolved

@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.

The previous TRIM/formatter blocker appears fixed, but the new reserved-function-name check rejects a valid qualified identifier under IGNORE_SPACE.

ident applies rejectSQLModeReservedFunctionName to every unquoted not_keyword/non_reserved_keyword token, including the component after .. In IGNORE_SPACE mode the helper rejects the name unconditionally. Thus SELECT src.count FROM src fails even though count is qualified; MySQL permits reserved words after the qualification dot. The new test currently marks this valid query as an expected error, locking in the regression.

Please distinguish an unqualified identifier used as a function name from a qualified identifier component. Keep the rejection for the unqualified reserved function name, but allow the name following .; change the test to assert the qualified query succeeds, and retain the quoted/unqualified controls. Please also cover qualified DDL names if they share this reduction.

@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 head 0ec424e57a6316ea297861752c4e6529d8320efb against current base 10ce23e7423d690ece19098e39a78b17236aa771.

The prior blockers are addressed: the identifier check now exempts components after the qualification dot, with positive qualified SELECT and CREATE TABLE coverage; generic TRIM/GROUP_CONCAT formatting is guarded by IsGeneric, and formatting/reparsing preserves the separator and UDF interpretation. Unqualified reserved names and quoted-name controls remain covered.

I reviewed the complete change map: scanner/function allowlist and generated grammar, mode propagation and plan-cache invalidation, AST formatting and binder/UDF dispatch, internal SHOW ACCOUNT SQL, and UT/BVT assertions including saved-mode PREPARE/view execution. The fix is appropriately scoped to parsing/binding. Lookahead adds bounded scanning at sensitive identifiers, with no new per-row execution work, background ownership, retry loop, or wire format. Normal, rejected, quoted, qualified, comment-separated, ANSI, and mode-change paths were considered; no remaining blocking defect was found.

Validation reused from this head: workflow 34681759104 passed owning UT/coverage, SCA, proxy BVT and pessimistic multi-CN BVT. No new local native test or performance run is claimed. Approval applies to the reviewed head.

@aptend aptend 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.

Deep re-review completed on exact head 0ec424e against exact current base 10ce23e. I read the complete review history, author replies, and resolved/outdated thread state, compared the changes after my prior reviewed head 31bcca6, and re-audited the full diff.

Both prior blockers are closed in code, not only by the replies: generic TRIM/GROUP_CONCAT formatting now respects IsGeneric and preserves the separator through format/reparse, while sensitive identifiers are rejected in the required unqualified contexts and remain valid after a qualification dot. The parser allowlist matches the documented MySQL 8.4 whitespace-sensitive set; mode propagation, plan-cache invalidation, saved-mode PREPARE/view behavior, internal SQL, and normal/error/quoted/comment-separated controls are coherent. I found no remaining blocking correctness, lifecycle, concurrency, wire-compatibility, or unbounded-work issue.

Validation on this exact head: deterministic parser regeneration and git diff --check passed; the full mysql parser package passed; focused IGNORE_SPACE parser/scanner tests passed under -race; focused planner/UDF-dispatch and frontend plan-cache/internal-SQL tests passed. Exact-head CI Required, Ubuntu UT, coverage, SCA, shared build, proxy BVT, and pessimistic multi-CN BVT are green. Approval applies to this head.

@mergify

mergify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-14 05:18 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-09-14 06:17 UTC · at 6987fda6c4a13295b8d525706342fc6033094d2e · squash

This pull request spent 58 minutes 38 seconds in the queue, including 58 minutes 17 seconds running CI.

Required conditions to merge

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

size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants