Repository navigation
fix(frontend): allow binary prepare for single SET assignment - #26694
mergify[bot] merged 5 commits into
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.
Deep review complete on exact head 223255882c8cbad48c661967f067ec3071a59d52; no blocking finding.
The grammar change closes only the binary COM_STMT_PREPARE entry gap by admitting one SET var_assignment. Multi-assignment remains rejected before planning, so this does not expose the separate #26685 panic/partial-update path. The real ExecRequest(COM_STMT_PREPARE) regression proves the retained tree.SetVar, one parameter slot, and rejection of two assignments.
The generated parser is reproducible from mysql_sql.y (only goyacc's output-path header differs when generated into a temp file) and reports zero conflicts. Exact-head validation: owning packages list/build/vet pass; full parser and frontend tests pass; focused test passes 10x and race passes 3x; git diff --check is clean.
Q1: the test-owned session and prepared statement are closed by the existing session lifecycle; no production resource owner changes. Q2: no new wait edge. Q3: a failed multi-assignment prepare is not installed in the prepared-statement registry, so no new accumulation path.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed the complete diff on exact head 223255882c8cbad48c661967f067ec3071a59d52. No P0, P1, P2, or P3 findings.
The new grammar branch admits exactly one SET var_assignment for the internal binary COM_STMT_PREPARE wrapper and constructs the same tree.SetVar used by the existing prepared-SET planner/executor path. A second top-level assignment remains a syntax error before planning, so this change does not expose the separate multi-assignment panic/partial-update path tracked by #26685. I also traced prepare registration, parameter metadata, execution-time expression binding, authorization, and session cleanup; the patch does not add a resource owner, wait edge, or hot-path work outside parsing.
Validation on this head: goyacc regeneration completed with zero conflicts and matched the committed parser body; git diff --check is clean; the MySQL parser package build, vet, and full tests passed locally. All 26 GitHub checks are complete with no failing or pending check, including the frontend/owning-package CI coverage.
|
@Mergifyio refresh |
✅ Pull request refreshed |
Merge Queue Status
This pull request spent 1 hour 9 minutes 51 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks: HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
Prepared multi-assignment `SET` evaluated each RHS through a derived `SELECT` in the session's shared `Process`. Cleanup after the first expression freed the outer prepared-parameter vector, so the next global parameter ordinal panicked. The recovered error also left the first session variable updated. Changes: - Fence the complete prepared-parameter state (`vector`, binary flags, and ownership) while a derived query frees its own resources, then restore the outer owner on every return or panic path. - Preserve direct `SET` left-to-right semantics for prepared user-variable assignments: evaluate and apply each assignment sequentially so a later RHS observes earlier targets. - Snapshot every unique target at statement entry and restore that original state on any later expression/apply failure or panic. Repeated/self-referential targets retain one rollback image instead of overwriting it after the first mutation. - Reject prepared multi-assignment `SET` containing a system variable before any RHS evaluation or mutation; prepared single-system assignment remains supported. - Add a defensive missing-parameter error instead of dereferencing a nil vector. - Extend binary prepared `SET` from one assignment to `var_assignment_list`. - Cover text and real binary protocol execution, rebinding, composite expressions, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, numeric/string/NULL values, invalid arity, failure atomicity, connection reuse, and final ownership cleanup. Non-goals: - This PR does not add a general rollback framework for apply-time side effects of mixed session/global/system-variable assignments; prepared multi-assignment statements containing system variables are intentionally unsupported. Validation: - Base behavior: FAIL on #26694 head `16c22842c93e2eca446c2ddab4ec58ba18180ea4` — the second parameter was unavailable after derived-query cleanup, while the first target variable had already changed. - CR falsification: FAIL before the ordering repair — both text and binary protocol regressions returned `@b = 6` instead of `42` when a later RHS referenced the earlier target. - Runtime regression: PASS on exact head `a08036a33fc4d00c00ebc6017445795112bad1be`, covering text PREPARE/EXECUTE and real `COM_STMT_PREPARE/EXECUTE`, left-to-right visibility, repeated targets, repeated-target rollback after a later RHS failure, mixed-target prevalidation, unchanged terminal state, and connection reuse. - Focused race: PASS on exact head, adaptive `-race -count=1` (`T=17.7s`, `B=30s`, `N=1`) for `TestIssue26685PreparedMultiSet`; Frontend owning-package race also passed once. - Owning packages: PASS for Frontend, Process, and MySQL parser; focused build and `go vet` passed. - BVT: PASS locally on the current built `mo-service`, `test/distributed/cases/prepare/prepare_all.sql` (394 total, 393 success, 1 existing ignore, 0 failed/abnormal). - Preflight: `PASS semantic=PASS exact-head=a08036a33fc4d00c00ebc6017445795112bad1be diff-hash=7d4de1a3cbfd3952646614618015180bac6118eda23db83d9937b188f9852f98`. - Diff hygiene: PASS, `git diff --check`. QA Decision - required: yes - reason: user-visible SQL compatibility, a deterministic recovered panic, and session-state failure atomicity - production_entrypoint: text PREPARE/EXECUTE and binary COM_STMT_PREPARE/EXECUTE - automated_terminal_coverage: user/system variables' final values, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, rebinding, NULL, invalid arity, failing later RHS, mixed-target rejection before mutation, single-system compatibility, connection reuse, and parameter ownership cleanup - remaining_validation: verify text and binary drivers on a deployed build after merge, including repeated rebinding and failure-state inspection Approved by: @heni02, @XuPeng-SH, @iamlinjunhong
…origin#26694) Binary `COM_STMT_PREPARE` wraps the client payload as `PREPARE <name> FROM <statement>`. The prepareable grammar admitted SELECT/DML statements but not `SET`, so `PrepareContext("SET @binary_value = ?")` failed with ERROR 1064 before parameter binding even though matrixorigin#26096 already supports planning and executing prepared SET expressions. This patch admits only `SET` with one variable assignment in that grammar and regenerates the MySQL parser. The regression goes through the real `ExecRequest(COM_STMT_PREPARE)` path, verifies the retained `tree.SetVar` plan and parameter metadata, and confirms binary multi-assignment remains rejected. The single-assignment boundary is intentional: prepared multi-assignment currently has a separate panic and partial-update atomicity defect tracked by matrixorigin#26685. This PR does not expose that known path or change SET execution semantics. Tested with: `go test -mod=readonly ./pkg/sql/parsers/dialect/mysql -count=1` `go test -mod=readonly ./pkg/frontend -count=1 -timeout=10m` `go vet -mod=readonly ./pkg/sql/parsers/dialect/mysql ./pkg/frontend` `go test -mod=readonly -race ./pkg/frontend -run "^TestExecRequestStmtPrepareAcceptsSetVariable$" -count=100` `go test -mod=readonly -race ./pkg/frontend -run "^TestPreparedSetBinaryProtocolReportsAndReplacesParameters$" -count=100` `go test -mod=readonly -race ./pkg/sql/parsers/dialect/mysql ./pkg/frontend -count=1` The parser generator completed with zero conflicts. CGo-transitive frontend commands used the repository third-party include/library and `libmo` linker configuration. Approved by: @XuPeng-SH, @iamlinjunhong
…n#26705) Prepared multi-assignment `SET` evaluated each RHS through a derived `SELECT` in the session's shared `Process`. Cleanup after the first expression freed the outer prepared-parameter vector, so the next global parameter ordinal panicked. The recovered error also left the first session variable updated. Changes: - Fence the complete prepared-parameter state (`vector`, binary flags, and ownership) while a derived query frees its own resources, then restore the outer owner on every return or panic path. - Preserve direct `SET` left-to-right semantics for prepared user-variable assignments: evaluate and apply each assignment sequentially so a later RHS observes earlier targets. - Snapshot every unique target at statement entry and restore that original state on any later expression/apply failure or panic. Repeated/self-referential targets retain one rollback image instead of overwriting it after the first mutation. - Reject prepared multi-assignment `SET` containing a system variable before any RHS evaluation or mutation; prepared single-system assignment remains supported. - Add a defensive missing-parameter error instead of dereferencing a nil vector. - Extend binary prepared `SET` from one assignment to `var_assignment_list`. - Cover text and real binary protocol execution, rebinding, composite expressions, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, numeric/string/NULL values, invalid arity, failure atomicity, connection reuse, and final ownership cleanup. Non-goals: - This PR does not add a general rollback framework for apply-time side effects of mixed session/global/system-variable assignments; prepared multi-assignment statements containing system variables are intentionally unsupported. Validation: - Base behavior: FAIL on matrixorigin#26694 head `16c22842c93e2eca446c2ddab4ec58ba18180ea4` — the second parameter was unavailable after derived-query cleanup, while the first target variable had already changed. - CR falsification: FAIL before the ordering repair — both text and binary protocol regressions returned `@b = 6` instead of `42` when a later RHS referenced the earlier target. - Runtime regression: PASS on exact head `a08036a33fc4d00c00ebc6017445795112bad1be`, covering text PREPARE/EXECUTE and real `COM_STMT_PREPARE/EXECUTE`, left-to-right visibility, repeated targets, repeated-target rollback after a later RHS failure, mixed-target prevalidation, unchanged terminal state, and connection reuse. - Focused race: PASS on exact head, adaptive `-race -count=1` (`T=17.7s`, `B=30s`, `N=1`) for `TestIssue26685PreparedMultiSet`; Frontend owning-package race also passed once. - Owning packages: PASS for Frontend, Process, and MySQL parser; focused build and `go vet` passed. - BVT: PASS locally on the current built `mo-service`, `test/distributed/cases/prepare/prepare_all.sql` (394 total, 393 success, 1 existing ignore, 0 failed/abnormal). - Preflight: `PASS semantic=PASS exact-head=a08036a33fc4d00c00ebc6017445795112bad1be diff-hash=7d4de1a3cbfd3952646614618015180bac6118eda23db83d9937b188f9852f98`. - Diff hygiene: PASS, `git diff --check`. QA Decision - required: yes - reason: user-visible SQL compatibility, a deterministic recovered panic, and session-state failure atomicity - production_entrypoint: text PREPARE/EXECUTE and binary COM_STMT_PREPARE/EXECUTE - automated_terminal_coverage: user/system variables' final values, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, rebinding, NULL, invalid arity, failing later RHS, mixed-target rejection before mutation, single-system compatibility, connection reuse, and parameter ownership cleanup - remaining_validation: verify text and binary drivers on a deployed build after merge, including repeated rebinding and failure-state inspection Approved by: @heni02, @XuPeng-SH, @iamlinjunhong
…origin#26694) Binary `COM_STMT_PREPARE` wraps the client payload as `PREPARE <name> FROM <statement>`. The prepareable grammar admitted SELECT/DML statements but not `SET`, so `PrepareContext("SET @binary_value = ?")` failed with ERROR 1064 before parameter binding even though matrixorigin#26096 already supports planning and executing prepared SET expressions. This patch admits only `SET` with one variable assignment in that grammar and regenerates the MySQL parser. The regression goes through the real `ExecRequest(COM_STMT_PREPARE)` path, verifies the retained `tree.SetVar` plan and parameter metadata, and confirms binary multi-assignment remains rejected. The single-assignment boundary is intentional: prepared multi-assignment currently has a separate panic and partial-update atomicity defect tracked by matrixorigin#26685. This PR does not expose that known path or change SET execution semantics. Tested with: `go test -mod=readonly ./pkg/sql/parsers/dialect/mysql -count=1` `go test -mod=readonly ./pkg/frontend -count=1 -timeout=10m` `go vet -mod=readonly ./pkg/sql/parsers/dialect/mysql ./pkg/frontend` `go test -mod=readonly -race ./pkg/frontend -run "^TestExecRequestStmtPrepareAcceptsSetVariable$" -count=100` `go test -mod=readonly -race ./pkg/frontend -run "^TestPreparedSetBinaryProtocolReportsAndReplacesParameters$" -count=100` `go test -mod=readonly -race ./pkg/sql/parsers/dialect/mysql ./pkg/frontend -count=1` The parser generator completed with zero conflicts. CGo-transitive frontend commands used the repository third-party include/library and `libmo` linker configuration. Approved by: @XuPeng-SH, @iamlinjunhong
…n#26705) Prepared multi-assignment `SET` evaluated each RHS through a derived `SELECT` in the session's shared `Process`. Cleanup after the first expression freed the outer prepared-parameter vector, so the next global parameter ordinal panicked. The recovered error also left the first session variable updated. Changes: - Fence the complete prepared-parameter state (`vector`, binary flags, and ownership) while a derived query frees its own resources, then restore the outer owner on every return or panic path. - Preserve direct `SET` left-to-right semantics for prepared user-variable assignments: evaluate and apply each assignment sequentially so a later RHS observes earlier targets. - Snapshot every unique target at statement entry and restore that original state on any later expression/apply failure or panic. Repeated/self-referential targets retain one rollback image instead of overwriting it after the first mutation. - Reject prepared multi-assignment `SET` containing a system variable before any RHS evaluation or mutation; prepared single-system assignment remains supported. - Add a defensive missing-parameter error instead of dereferencing a nil vector. - Extend binary prepared `SET` from one assignment to `var_assignment_list`. - Cover text and real binary protocol execution, rebinding, composite expressions, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, numeric/string/NULL values, invalid arity, failure atomicity, connection reuse, and final ownership cleanup. Non-goals: - This PR does not add a general rollback framework for apply-time side effects of mixed session/global/system-variable assignments; prepared multi-assignment statements containing system variables are intentionally unsupported. Validation: - Base behavior: FAIL on matrixorigin#26694 head `16c22842c93e2eca446c2ddab4ec58ba18180ea4` — the second parameter was unavailable after derived-query cleanup, while the first target variable had already changed. - CR falsification: FAIL before the ordering repair — both text and binary protocol regressions returned `@b = 6` instead of `42` when a later RHS referenced the earlier target. - Runtime regression: PASS on exact head `a08036a33fc4d00c00ebc6017445795112bad1be`, covering text PREPARE/EXECUTE and real `COM_STMT_PREPARE/EXECUTE`, left-to-right visibility, repeated targets, repeated-target rollback after a later RHS failure, mixed-target prevalidation, unchanged terminal state, and connection reuse. - Focused race: PASS on exact head, adaptive `-race -count=1` (`T=17.7s`, `B=30s`, `N=1`) for `TestIssue26685PreparedMultiSet`; Frontend owning-package race also passed once. - Owning packages: PASS for Frontend, Process, and MySQL parser; focused build and `go vet` passed. - BVT: PASS locally on the current built `mo-service`, `test/distributed/cases/prepare/prepare_all.sql` (394 total, 393 success, 1 existing ignore, 0 failed/abnormal). - Preflight: `PASS semantic=PASS exact-head=a08036a33fc4d00c00ebc6017445795112bad1be diff-hash=7d4de1a3cbfd3952646614618015180bac6118eda23db83d9937b188f9852f98`. - Diff hygiene: PASS, `git diff --check`. QA Decision - required: yes - reason: user-visible SQL compatibility, a deterministic recovered panic, and session-state failure atomicity - production_entrypoint: text PREPARE/EXECUTE and binary COM_STMT_PREPARE/EXECUTE - automated_terminal_coverage: user/system variables' final values, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, rebinding, NULL, invalid arity, failing later RHS, mixed-target rejection before mutation, single-system compatibility, connection reuse, and parameter ownership cleanup - remaining_validation: verify text and binary drivers on a deployed build after merge, including repeated rebinding and failure-state inspection Approved by: @heni02, @XuPeng-SH, @iamlinjunhong
…origin#26694) Binary `COM_STMT_PREPARE` wraps the client payload as `PREPARE <name> FROM <statement>`. The prepareable grammar admitted SELECT/DML statements but not `SET`, so `PrepareContext("SET @binary_value = ?")` failed with ERROR 1064 before parameter binding even though matrixorigin#26096 already supports planning and executing prepared SET expressions. This patch admits only `SET` with one variable assignment in that grammar and regenerates the MySQL parser. The regression goes through the real `ExecRequest(COM_STMT_PREPARE)` path, verifies the retained `tree.SetVar` plan and parameter metadata, and confirms binary multi-assignment remains rejected. The single-assignment boundary is intentional: prepared multi-assignment currently has a separate panic and partial-update atomicity defect tracked by matrixorigin#26685. This PR does not expose that known path or change SET execution semantics. Tested with: `go test -mod=readonly ./pkg/sql/parsers/dialect/mysql -count=1` `go test -mod=readonly ./pkg/frontend -count=1 -timeout=10m` `go vet -mod=readonly ./pkg/sql/parsers/dialect/mysql ./pkg/frontend` `go test -mod=readonly -race ./pkg/frontend -run "^TestExecRequestStmtPrepareAcceptsSetVariable$" -count=100` `go test -mod=readonly -race ./pkg/frontend -run "^TestPreparedSetBinaryProtocolReportsAndReplacesParameters$" -count=100` `go test -mod=readonly -race ./pkg/sql/parsers/dialect/mysql ./pkg/frontend -count=1` The parser generator completed with zero conflicts. CGo-transitive frontend commands used the repository third-party include/library and `libmo` linker configuration. Approved by: @XuPeng-SH, @iamlinjunhong
…n#26705) Prepared multi-assignment `SET` evaluated each RHS through a derived `SELECT` in the session's shared `Process`. Cleanup after the first expression freed the outer prepared-parameter vector, so the next global parameter ordinal panicked. The recovered error also left the first session variable updated. Changes: - Fence the complete prepared-parameter state (`vector`, binary flags, and ownership) while a derived query frees its own resources, then restore the outer owner on every return or panic path. - Preserve direct `SET` left-to-right semantics for prepared user-variable assignments: evaluate and apply each assignment sequentially so a later RHS observes earlier targets. - Snapshot every unique target at statement entry and restore that original state on any later expression/apply failure or panic. Repeated/self-referential targets retain one rollback image instead of overwriting it after the first mutation. - Reject prepared multi-assignment `SET` containing a system variable before any RHS evaluation or mutation; prepared single-system assignment remains supported. - Add a defensive missing-parameter error instead of dereferencing a nil vector. - Extend binary prepared `SET` from one assignment to `var_assignment_list`. - Cover text and real binary protocol execution, rebinding, composite expressions, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, numeric/string/NULL values, invalid arity, failure atomicity, connection reuse, and final ownership cleanup. Non-goals: - This PR does not add a general rollback framework for apply-time side effects of mixed session/global/system-variable assignments; prepared multi-assignment statements containing system variables are intentionally unsupported. Validation: - Base behavior: FAIL on matrixorigin#26694 head `16c22842c93e2eca446c2ddab4ec58ba18180ea4` — the second parameter was unavailable after derived-query cleanup, while the first target variable had already changed. - CR falsification: FAIL before the ordering repair — both text and binary protocol regressions returned `@b = 6` instead of `42` when a later RHS referenced the earlier target. - Runtime regression: PASS on exact head `a08036a33fc4d00c00ebc6017445795112bad1be`, covering text PREPARE/EXECUTE and real `COM_STMT_PREPARE/EXECUTE`, left-to-right visibility, repeated targets, repeated-target rollback after a later RHS failure, mixed-target prevalidation, unchanged terminal state, and connection reuse. - Focused race: PASS on exact head, adaptive `-race -count=1` (`T=17.7s`, `B=30s`, `N=1`) for `TestIssue26685PreparedMultiSet`; Frontend owning-package race also passed once. - Owning packages: PASS for Frontend, Process, and MySQL parser; focused build and `go vet` passed. - BVT: PASS locally on the current built `mo-service`, `test/distributed/cases/prepare/prepare_all.sql` (394 total, 393 success, 1 existing ignore, 0 failed/abnormal). - Preflight: `PASS semantic=PASS exact-head=a08036a33fc4d00c00ebc6017445795112bad1be diff-hash=7d4de1a3cbfd3952646614618015180bac6118eda23db83d9937b188f9852f98`. - Diff hygiene: PASS, `git diff --check`. QA Decision - required: yes - reason: user-visible SQL compatibility, a deterministic recovered panic, and session-state failure atomicity - production_entrypoint: text PREPARE/EXECUTE and binary COM_STMT_PREPARE/EXECUTE - automated_terminal_coverage: user/system variables' final values, left-to-right visibility, repeated/self-referential targets, repeated-target rollback, rebinding, NULL, invalid arity, failing later RHS, mixed-target rejection before mutation, single-system compatibility, connection reuse, and parameter ownership cleanup - remaining_validation: verify text and binary drivers on a deployed build after merge, including repeated rebinding and failure-state inspection Approved by: @heni02, @XuPeng-SH, @iamlinjunhong
What type of PR is this?
Which issue(s) this PR fixes:
issue #25996
What this PR does / why we need it:
Binary
COM_STMT_PREPAREwraps the client payload asPREPARE <name> FROM <statement>. The prepareable grammar admitted SELECT/DML statements but notSET, soPrepareContext("SET @binary_value = ?")failed with ERROR 1064 before parameter binding even though #26096 already supports planning and executing prepared SET expressions.This patch admits only
SETwith one variable assignment in that grammar and regenerates the MySQL parser. The regression goes through the realExecRequest(COM_STMT_PREPARE)path, verifies the retainedtree.SetVarplan and parameter metadata, and confirms binary multi-assignment remains rejected.The single-assignment boundary is intentional: prepared multi-assignment currently has a separate panic and partial-update atomicity defect tracked by #26685. This PR does not expose that known path or change SET execution semantics.
Tested with:
go test -mod=readonly ./pkg/sql/parsers/dialect/mysql -count=1go test -mod=readonly ./pkg/frontend -count=1 -timeout=10mgo vet -mod=readonly ./pkg/sql/parsers/dialect/mysql ./pkg/frontendgo test -mod=readonly -race ./pkg/frontend -run "^TestExecRequestStmtPrepareAcceptsSetVariable$" -count=100go test -mod=readonly -race ./pkg/frontend -run "^TestPreparedSetBinaryProtocolReportsAndReplacesParameters$" -count=100go test -mod=readonly -race ./pkg/sql/parsers/dialect/mysql ./pkg/frontend -count=1The parser generator completed with zero conflicts. CGo-transitive frontend commands used the repository third-party include/library and
libmolinker configuration.