Repository navigation
fix(frontend): support prepared EXPLAIN statements - #26046
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head f3f35e6. The PREPARE/EXECUTE closure preserves the saved ExplainStmt while rendering the initialized or schema-replanned inner plan; parameter substitution deep-copies the reusable template, binary parameter values are copied before vector cleanup, protocol metadata matches direct EXPLAIN, and authorization is applied to the inner statement. The execution routing returns through the frontend handler without running the underlying query.
Local verification:
- focused planner/frontend regression tests: -race -count=20
- full ./pkg/sql/plan and ./pkg/frontend test suites
- go vet ./pkg/sql/plan ./pkg/frontend
- go build ./pkg/sql/plan ./pkg/frontend
All relevant CI checks are green.
Merge Queue Status
This pull request spent 8 minutes 59 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
f3f35e6 to
5944904
Compare
Merge Queue Status
This pull request spent 25 minutes 55 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #26046 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25991 ## What this PR does / why we need it: PREPARE previously sent a normal ExplainStmt through the generic planner, which had no matching branch and returned an internal error. Handling only that planner branch is insufficient because EXECUTE must retain EXPLAIN semantics across schema replanning, parameter binding, protocol metadata, and authorization. This PR: - plans the inner query for a prepared EXPLAIN while retaining the saved ExplainStmt for execution routing; - renders the initialized or schema-replanned prepared plan instead of rebuilding the original query, so the underlying SELECT is never executed; - substitutes both text-protocol and binary-protocol parameters into a copied plan before rendering; - reports the same single dynamic result column as direct EXPLAIN for COM_STMT_PREPARE; - authorizes the inner statement rather than treating EXPLAIN as an unprivileged wrapper; and - adds planner, execution, parameter, and wire-metadata regression tests. ## Testing - .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan -count=1 - .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1 - targeted race tests for the new plan and frontend paths - go vet -mod=readonly ./pkg/sql/plan ./pkg/frontend Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25991 ## What this PR does / why we need it: PREPARE previously sent a normal ExplainStmt through the generic planner, which had no matching branch and returned an internal error. Handling only that planner branch is insufficient because EXECUTE must retain EXPLAIN semantics across schema replanning, parameter binding, protocol metadata, and authorization. This PR: - plans the inner query for a prepared EXPLAIN while retaining the saved ExplainStmt for execution routing; - renders the initialized or schema-replanned prepared plan instead of rebuilding the original query, so the underlying SELECT is never executed; - substitutes both text-protocol and binary-protocol parameters into a copied plan before rendering; - reports the same single dynamic result column as direct EXPLAIN for COM_STMT_PREPARE; - authorizes the inner statement rather than treating EXPLAIN as an unprivileged wrapper; and - adds planner, execution, parameter, and wire-metadata regression tests. ## Testing - .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan -count=1 - .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1 - targeted race tests for the new plan and frontend paths - go vet -mod=readonly ./pkg/sql/plan ./pkg/frontend Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#25991 ## What this PR does / why we need it: PREPARE previously sent a normal ExplainStmt through the generic planner, which had no matching branch and returned an internal error. Handling only that planner branch is insufficient because EXECUTE must retain EXPLAIN semantics across schema replanning, parameter binding, protocol metadata, and authorization. This PR: - plans the inner query for a prepared EXPLAIN while retaining the saved ExplainStmt for execution routing; - renders the initialized or schema-replanned prepared plan instead of rebuilding the original query, so the underlying SELECT is never executed; - substitutes both text-protocol and binary-protocol parameters into a copied plan before rendering; - reports the same single dynamic result column as direct EXPLAIN for COM_STMT_PREPARE; - authorizes the inner statement rather than treating EXPLAIN as an unprivileged wrapper; and - adds planner, execution, parameter, and wire-metadata regression tests. ## Testing - .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan -count=1 - .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1 - targeted race tests for the new plan and frontend paths - go vet -mod=readonly ./pkg/sql/plan ./pkg/frontend Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #25991
What this PR does / why we need it:
PREPARE previously sent a normal ExplainStmt through the generic planner, which had no matching branch and returned an internal error. Handling only that planner branch is insufficient because EXECUTE must retain EXPLAIN semantics across schema replanning, parameter binding, protocol metadata, and authorization.
This PR:
Testing