Repository navigation
fix(frontend): preserve params across prepared multi-SET - #26705
mergify[bot] merged 7 commits into
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 30c68fa672a13acc3077644ae0dc01d9f101644f. The previous left-to-right visibility blocker is fixed, and the normal text/binary regressions pass. One failure-atomicity blocker remains.
[P1] Snapshot the effective mutation set, not only assign.Name
The prepared-multi preflight treats every assignment with assign.System == false as a rollback-safe user-variable write. However, applyAssignment dispatches several special SET operations only by the lower-cased name, without checking assign.System. Consequently, the syntactic user assignment @names reaches the name == "names" branch and expands into writes to character_set_client, character_set_connection, and character_set_results, while the rollback snapshot contains only names and the other syntactic assignment names.
I reproduced this on this exact head through the public text PREPARE path:
set @character_set_client = 'client-before',
@character_set_connection = 'connection-before',
@character_set_results = 'results-before';
prepare p from
'set @names = ?, @failure = (select v from values_for_error)';
set @input = 'mutated';
execute p using @input;With values_for_error containing two rows, the second RHS correctly fails with Subquery returns more than 1 row, but all three character-set variables remain mutated; the expected result is the three *-before values. Thus a failed prepared multi-SET still leaves partial session mutation, which is the core contract of #26685.
The same dispatch/snapshot mismatch also applies to reserved user-variable spellings such as @clear_privilege_cache, @enable_privilege_cache, @optimizer_hints, and the runtime-filter knobs: those branches can mutate cache/session/runtime state that the user-variable map rollback cannot restore.
Please make the prepared-multi path distinguish ordinary user-variable assignments from special SET operations before applying them. In particular, special handlers should be guarded by the actual assignment kind, and unsupported/non-rollbackable operations should be rejected before the first mutation (or their complete effective target/side-effect set must be included in the rollback plan). Please add both text- and binary-protocol regressions with a later RHS failure for this reserved-name case.
|
Addressed the current-head CHANGES_REQUESTED finding on 5eb2f91.
Validation on the exact committed head: focused and full parser/process/frontend/issues packages PASS; go build PASS; go vet PASS; git diff --check PASS; schema-v6 semantic preflight PASS. Exact-head CI is now pending. @XuPeng-SH please re-review the updated head. |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed exact head 5eb2f9143806bd77924c7704403d98b5f6f2bef8 against merge-base 09e02eea38bfa87e4c4333ffb57b370091136bc8 (with current origin/main at a3f3f06fec231b595db5b9ad1a6b347bc067b83e).
Findings: none (P0–P3).
I traced the prepared-parameter ownership path through detach/borrow/nested cleanup/restore, the sequential multi-assignment evaluation and rollback paths (including repeated targets, errors, and panic unwinding), the parser assignment-kind changes, both text and binary prepare entry points, and the focused/BVT coverage. The prior left-to-right visibility and reserved user-variable dispatch blockers are closed on this head. The current main merge is clean, and all 26 reported checks are completed with accepted conclusions.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 5eb2f9143806bd77924c7704403d98b5f6f2bef8.
The two previous blockers are closed on this head:
- Prepared multi-user-variable assignments now preserve direct
SET's left-to-right visibility while retaining statement-entry snapshots for error and panic rollback, including repeated/self-referential targets. - Special SET behavior is now selected by syntax/assignment kind (
SetNamesorSystem), not merely by a reserved spelling, so user variables such as@namesand the other handler-shaped names cannot escape the rollback set through unrelated session/runtime side effects.
I also traced the prepare-parameter ownership lifecycle through detach -> non-owning borrow -> nested Process.Free -> restore. The nested cleanup cannot free the outer owned parameter vector, and restoration is deferred across cleanup panics. The nil/bounds guard in GetPrepareParamsAt closes the reported crash path.
Local exact-head validation passed:
TestIssue26685PreparedMultiSetthrough both text PREPARE/EXECUTE and binary COM_STMT_PREPARE/COM_STMT_EXECUTE, covering rebinding/NULL, sequential visibility, repeated targets, late RHS failure rollback, reserved user-variable names, mixed system-variable rejection, and connection reuse.- Focused parser assignment-kind, Process ownership/nil-parameter, and frontend multi-SET prepare tests.
git diff --check.
Current GitHub checks are complete with no failures. No blocking findings remain.
Merge Queue Status
This pull request spent 53 minutes 28 seconds in the queue, including 42 minutes 18 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #26685
What this PR does / why we need it:
Prepared multi-assignment
SETevaluated each RHS through a derivedSELECTin the session's sharedProcess. 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:
vector, binary flags, and ownership) while a derived query frees its own resources, then restore the outer owner on every return or panic path.SETleft-to-right semantics for prepared user-variable assignments: evaluate and apply each assignment sequentially so a later RHS observes earlier targets.SETcontaining a system variable before any RHS evaluation or mutation; prepared single-system assignment remains supported.SETfrom one assignment tovar_assignment_list.Non-goals:
Validation:
16c22842c93e2eca446c2ddab4ec58ba18180ea4— the second parameter was unavailable after derived-query cleanup, while the first target variable had already changed.@b = 6instead of42when a later RHS referenced the earlier target.a08036a33fc4d00c00ebc6017445795112bad1be, covering text PREPARE/EXECUTE and realCOM_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.-race -count=1(T=17.7s,B=30s,N=1) forTestIssue26685PreparedMultiSet; Frontend owning-package race also passed once.go vetpassed.mo-service,test/distributed/cases/prepare/prepare_all.sql(394 total, 393 success, 1 existing ignore, 0 failed/abnormal).PASS semantic=PASS exact-head=a08036a33fc4d00c00ebc6017445795112bad1be diff-hash=7d4de1a3cbfd3952646614618015180bac6118eda23db83d9937b188f9852f98.git diff --check.QA Decision