Skip to content

fix: backport SQL syntax/operator compatibility to 3.0-dev - #24196

Merged
11 commits merged into
matrixorigin:3.0-devfrom
LeftHandCold:3.0-dev
Apr 28, 2026
Merged

11 commits merged into
matrixorigin:3.0-devfrom
LeftHandCold:3.0-dev

Conversation

@LeftHandCold

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 fixes:

fixes #24183

What this PR does / why we need it:

Backport SQL syntax/operator compatibility fixes to 3.0-dev for issue #24183.

This PR completes the 3.0-dev implementation of:

  • MySQL JSON operators -> and ->>
  • NULL-safe equal operator <=>
  • multi-table DROP TABLE

During review, it also closes several correctness gaps needed to make the backport safe on 3.0-dev:

  • exact-vs-approx mixed numeric comparison fallback behavior
  • JSON-to-numeric precision and overflow handling
  • multi-drop privilege checks, FK-linked drops, and child-first drop order handling

The change is implemented directly on 3.0-dev instead of cherry-picking the main branch patches verbatim, because this branch already had partial/incomplete wiring and diverges enough that a manual backport is lower risk.

Copilot AI review requested due to automatic review settings April 24, 2026 07:21
@LeftHandCold
LeftHandCold requested a review from a user April 24, 2026 07:21
@mergify mergify Bot added the kind/bug Something isn't working label Apr 24, 2026
@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Apr 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Backports several MySQL-compatibility SQL surface features to 3.0-dev (JSON -> / ->>, null-safe equal <=>, and multi-table DROP TABLE) and fills in related correctness gaps (mixed numeric comparisons and JSON-to-numeric casting), with corresponding parser/binder/plan/execution wiring and tests.

Changes:

  • Add parser + binder + function support for <=> and JSON arrow operators -> / ->>.
  • Implement multi-table DROP TABLE planning/execution via DropTable.tables, including FK/privilege handling updates.
  • Improve mixed numeric comparison fallback and JSON→numeric cast behavior; add distributed + unit test coverage.

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/distributed/cases/function/func_null_safe_equal.sql Distributed SQL coverage for <=> operator behavior.
test/distributed/cases/function/func_null_safe_equal.result Expected results for <=> distributed test.
test/distributed/cases/function/func_json_arrow.sql Distributed SQL coverage for JSON -> / ->> operators.
test/distributed/cases/function/func_json_arrow.result Expected results for JSON arrow distributed test.
test/distributed/cases/ddl/drop_table_multiple.sql Distributed SQL coverage for multi-table DROP TABLE.
test/distributed/cases/ddl/drop_table_multiple.result Expected results for multi-drop distributed test.
proto/plan.proto Extend DropTable plan node to carry per-table entries for multi-drop.
pkg/sql/plan/function/list_operator.go Register <=> operator and type-check/casting rules.
pkg/sql/plan/function/init.go Add encoded ID/name constants for <=>.
pkg/sql/plan/function/function_id.go Allocate a new function ID and register <=> operator name.
pkg/sql/plan/function/function_id_test.go Update function ID map to include <=>.
pkg/sql/plan/function/func_compare.go Implement runtime execution for <=> and update mismatch-compare callsites.
pkg/sql/plan/function/func_compare_fix.go Rework numeric type-mismatch fallback to avoid cross-type precision loss.
pkg/sql/plan/function/func_compare_test.go Add unit tests for mixed numeric compare and <=>.
pkg/sql/plan/function/func_cast.go Enable JSON→numeric casts with overflow/precision handling.
pkg/sql/plan/function/func_cast_test.go Add unit tests for JSON→integer precision/overflow.
pkg/sql/plan/deepcopy.go Ensure DropTable deep copy covers multi-drop entries.
pkg/sql/plan/build_ddl.go Build multi-table DROP TABLE plans + FK-target logic.
pkg/sql/plan/base_binder.go Bind <=> comparisons (including tuple support).
pkg/sql/parsers/dialect/mysql/scanner.go Lex ->> as a distinct token.
pkg/sql/parsers/dialect/mysql/mysql_sql.y Parse -> / ->> and rewrite into JSON function calls.
pkg/sql/parsers/dialect/mysql/mysql_sql_test.go Parser round-trip tests for JSON arrow operators.
pkg/sql/compile/ddl.go Execute multi-drop by iterating per-table DropTable entries.
pkg/frontend/authenticate.go Update privilege checking/implicit revokes for multi-table DROP TABLE.

Comment thread pkg/frontend/authenticate.go Resolved
Comment thread pkg/sql/compile/ddl.go Resolved
Comment thread pkg/sql/plan/build_ddl.go Resolved
Comment thread pkg/sql/plan/base_binder.go Resolved
Comment thread pkg/frontend/authenticate.go Resolved
This pull request was closed.

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 size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants