Repository navigation
fix(frontend): deallocate stale statement before re-PREPARE - #26258
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 98d1d8b.
The replacement boundary is correct: once the outer PREPARE parses to a named AST, the old map owner is closed before transaction admission, planning, and authorization, so every failed replacement path leaves no stale executable statement. Case-normalized Set/Get/Remove closes the mixed-case gap and preserves quota accounting. I also checked the interaction with latest main's prepared-AST ownership changes; the removed object and the incoming wrapper own distinct ASTs, so there is no double-free edge.
Verified against MySQL 8.0.44 for inner parse failure, missing user variable, mixed-case replacement, and outer PREPARE syntax failure (the latter correctly retains the old statement because no replacement AST exists). Prospectively merged cleanly onto latest main 2dd3f83. Focused tests passed normally and under -race for 33 iterations; full pkg/frontend -race, pkg/common/malloc -race, go vet, and diff checks passed (the only diff-check whitespace findings are pre-existing latest-main enum result formatting). CI is green.
Merge Queue Status
This pull request spent 40 minutes 17 seconds in the queue, with no time running CI. ReasonThe pull request #26258 has been manually updated Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/frontend/session.go # pkg/frontend/session_test.go
Merge Queue Status
This pull request spent 1 hour 40 minutes 2 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #26258 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.
Failing checks:
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?
Which issue(s) this PR fixes:
Fixes #25977
What this PR does / why we need it:
MySQL deallocates an existing prepared statement before attempting to prepare
another statement with the same name. MatrixOne previously kept the old
statement until the replacement was successfully built, so a parse,
authorization, or planning failure left stale SQL executable under that name.
This change removes and closes the existing statement at the frontend PREPARE
dispatch boundary before building the replacement. It applies consistently to
direct statements, string literals, and user-variable PREPARE forms. If the new
PREPARE fails, a later EXECUTE now reports that the prepared statement does not
exist.
Regression coverage verifies planning failures, inner SQL parse failures,
missing user variables, resource cleanup, and successful reuse after a failed
replacement.
Validation:
go vet ./pkg/frontend/...make buildpkg/frontendunit testsprepare_reprepare.test: 15/15 passed