Skip to content

fix(frontend): support prepared SET statements - #26096

Merged
mergify[bot] merged 12 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25996-prepared-set
Jul 28, 2026
Merged

mergify[bot] merged 12 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25996-prepared-set

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:

issue #25996

What this PR does / why we need it:

Prepared SET was rejected because the DCL carrier did not retain ordered parameter metadata and SET expression evaluation lost prepared context when it synthesized internal SELECT statements.

This change collects parameters and schemas from retained SET expressions plus transient scalar-subquery plans, preserves global parser ordinals across multiple assignments, explicitly propagates prepared mode through initial and retry planning, bypasses invalid empty-SQL plan-cache keys for SET-derived AST inputs, and preserves decimal result binding. Supplemental aggregate/window traversal is idempotent with the generic visitor work in #26042 and #26094.

The saved prepared AST and DCL plan remain immutable during EXECUTE. Text and binary repeated execution, multiple markers, NULL replacement, scalar/nested subqueries, aggregate/window fields, decimal expressions, cache isolation, and retry rebuilding are covered.

Tested with:

./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan ./pkg/frontend

./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run "TestPreparedSet|TestSetExpression|TestPreparedSetExpression" -count=1 -timeout=240s ./pkg/frontend

Configured go build and go vet passed for planner/frontend. The distributed SQL fixture is included for CI; local mo-tester was unavailable.

@LeftHandCold
LeftHandCold requested a review from a user July 23, 2026 08:24
@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 →

@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Jul 23, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Jul 23, 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.

Deep-reviewed exact head f154b46. The prepared SET path is functionally closed across parameter discovery/order, nested scalar-subquery metadata, prepared-context propagation through initial and retry planning, AST-only cache bypass, result rebinding, and retained-plan/AST immutability. I also traced cleanup/retry ownership and did not find a blocking correctness or lifecycle issue.

Verified locally on the exact head: full pkg/sql/plan and pkg/frontend tests, focused prepared-SET/planner tests under -race, and git diff --check all pass. The two red CI jobs are not attributable to this diff: Iceberg failed during external module download with HTTP 502, and Ubuntu UT failed only in the unrelated TAE TestCkpLeak checkpoint timeout.

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

@mergify

mergify Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-28 09:32 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-28 12:29 UTC · at b11476d3f17e455b03cc179c3ccb575e1209008a · squash

This pull request spent 2 hours 57 minutes 23 seconds in the queue, including 34 minutes 10 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • 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 CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • 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 UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants