Repository navigation
fix(frontend): reject unknown prepared deallocation - #26259
Conversation
# Conflicts: # pkg/frontend/session.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head c935282ec65b18d27def1a84f85afd86e4a7f656. The text-protocol path now atomically distinguishes present vs. missing prepared statements and returns MySQL 1243/HY000, while internal cleanup remains idempotent by intentionally ignoring the boolean. I separately traced COM_STMT_CLOSE: its lookup/rewrite and ROW_COUNT handling remain on the protocol path, so this change does not conflate SQL DEALLOCATE PREPARE with binary close semantics. The create_role BVT adjustment is also correct: cleanup was previously issued after switching out of the session that owned the statements; it is now performed in the owning session, and stmt4 is correctly omitted because its prepare failed authorization.
Exact-head validation:
TestNew_MyErrorCode,TestRemovePrepareStmt,Test_HandleDeallocate, andTest_ExecRequestPrepareCommandMissingStmteach passed independently with-race -count=100- full
pkg/common/moerr/...andpkg/frontendpassed under race - exact-head standalone text-protocol regression passed 3 consecutive runs: two 1243/HY000 errors per run and subsequent statements continued normally
- CI logs confirm the modified
result_count.sqlandcreate_role.sqlwere actually executed successfully make build, affected-packagego vet, andgit diff --checkpassed- CI Summary/UT/SCA/BVT/Iceberg/coverage passed; current-main merge-tree is conflict-free
No blocking findings.
Merge Queue Status
This pull request spent 1 hour 59 minutes 42 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #26259 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? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25978 ## What this PR does / why we need it: Text-protocol `DEALLOCATE PREPARE` previously succeeded silently when the named prepared statement did not exist or had already been deallocated. The session removal API unconditionally deleted the map key and did not report whether an entry was present. This change: - makes prepared-statement removal atomically report whether the statement existed; - returns MySQL-compatible error 1243 (`HY000`) for an unknown statement handler; - keeps internal cleanup paths idempotent when they intentionally ignore the removal result; - adds unit coverage and a text-protocol BVT for missing and repeated deallocation. Validation: - `go test -count=1 -timeout=120s ./pkg/common/moerr/...` - `go build ./pkg/common/moerr/... ./pkg/frontend/...` - `go vet ./pkg/common/moerr/... ./pkg/frontend/...` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/frontend` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s -run 'TestRemovePrepareStmt|Test_HandleDeallocate' ./pkg/frontend` - `golangci-lint run -c .golangci.yml ./pkg/common/moerr ./pkg/frontend` - `mo-tester` BVT: `deallocate_unknown.sql` (6/6) The repository-wide `make static-check` reaches two existing `unused` findings in `pkg/common/malloc/sane_allocator_cache.go`; the same findings reproduce on the clean base commit. --------- 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: Fixes matrixorigin#25978 ## What this PR does / why we need it: Text-protocol `DEALLOCATE PREPARE` previously succeeded silently when the named prepared statement did not exist or had already been deallocated. The session removal API unconditionally deleted the map key and did not report whether an entry was present. This change: - makes prepared-statement removal atomically report whether the statement existed; - returns MySQL-compatible error 1243 (`HY000`) for an unknown statement handler; - keeps internal cleanup paths idempotent when they intentionally ignore the removal result; - adds unit coverage and a text-protocol BVT for missing and repeated deallocation. Validation: - `go test -count=1 -timeout=120s ./pkg/common/moerr/...` - `go build ./pkg/common/moerr/... ./pkg/frontend/...` - `go vet ./pkg/common/moerr/... ./pkg/frontend/...` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/frontend` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s -run 'TestRemovePrepareStmt|Test_HandleDeallocate' ./pkg/frontend` - `golangci-lint run -c .golangci.yml ./pkg/common/moerr ./pkg/frontend` - `mo-tester` BVT: `deallocate_unknown.sql` (6/6) The repository-wide `make static-check` reaches two existing `unused` findings in `pkg/common/malloc/sane_allocator_cache.go`; the same findings reproduce on the clean base commit. --------- 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: Fixes matrixorigin#25978 ## What this PR does / why we need it: Text-protocol `DEALLOCATE PREPARE` previously succeeded silently when the named prepared statement did not exist or had already been deallocated. The session removal API unconditionally deleted the map key and did not report whether an entry was present. This change: - makes prepared-statement removal atomically report whether the statement existed; - returns MySQL-compatible error 1243 (`HY000`) for an unknown statement handler; - keeps internal cleanup paths idempotent when they intentionally ignore the removal result; - adds unit coverage and a text-protocol BVT for missing and repeated deallocation. Validation: - `go test -count=1 -timeout=120s ./pkg/common/moerr/...` - `go build ./pkg/common/moerr/... ./pkg/frontend/...` - `go vet ./pkg/common/moerr/... ./pkg/frontend/...` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/frontend` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s -run 'TestRemovePrepareStmt|Test_HandleDeallocate' ./pkg/frontend` - `golangci-lint run -c .golangci.yml ./pkg/common/moerr ./pkg/frontend` - `mo-tester` BVT: `deallocate_unknown.sql` (6/6) The repository-wide `make static-check` reaches two existing `unused` findings in `pkg/common/malloc/sane_allocator_cache.go`; the same findings reproduce on the clean base commit. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #25978
What this PR does / why we need it:
Text-protocol
DEALLOCATE PREPAREpreviously succeeded silently when the namedprepared statement did not exist or had already been deallocated. The session
removal API unconditionally deleted the map key and did not report whether an
entry was present.
This change:
existed;
HY000) for an unknown statementhandler;
removal result;
deallocation.
Validation:
go test -count=1 -timeout=120s ./pkg/common/moerr/...go build ./pkg/common/moerr/... ./pkg/frontend/...go vet ./pkg/common/moerr/... ./pkg/frontend/....agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=240s -run 'TestRemovePrepareStmt|Test_HandleDeallocate' ./pkg/frontendgolangci-lint run -c .golangci.yml ./pkg/common/moerr ./pkg/frontendmo-testerBVT:deallocate_unknown.sql(6/6)The repository-wide
make static-checkreaches two existingunusedfindingsin
pkg/common/malloc/sane_allocator_cache.go; the same findings reproduce onthe clean base commit.