Repository navigation
Description
Environment
- Workspace commit:
f14a1fa9ee813529b7bde89ecc74dddca420dc00(main; includesef502446dc/ feat: support EXPLAIN FORMAT=JSON #28435 that added EXPLAIN FORMAT=JSON andf14a1fa9ee/ fix(explain): align shared index scans and preserve search settings #30111 that aligned index search scans). - OS: macOS 15.5 (BuildVersion 24F74), arm64.
- Build:
make buildfrom the workspace; single-nodemo-service -launch .loom-test/launch/launch.toml(standalone LOG/TN/CN, MySQL port offset). - Client:
mysql9.7.1 (Homebrew) connected to the single-node CN.
Actual Behavior
EXPLAIN FORMAT=JSON for an UPDATE renders the assignments value fields as opaque internal column references (#[0,0], #[0,1]) instead of the assigned expressions, even though the documented contract requires the actual value (docs/design/explain_format_json.md: "a plan for SET v = 2 includes a value of 2").
For update t set v = 2 where id = 1 the Multi Update node is:
{"id":"4","operator":"Multi Update","inputs":["3"],"table_names":["ub.t"],
"assignments":[{"target":"ub.t.id","value":"#[0,0]"},{"target":"ub.t.v","value":"#[0,1]"}]}The real assigned value 2 is present only one node lower, on the reachable Project (node 2):
{"id":"2","operator":"Project","inputs":["1"],"projection":["t.id","2","t.__mo_rowid","(not (t.v <=> 2))"]}The same happens for expression sets and for unchanged columns: update t set v = v + 1 where id = 1 also yields value":"#[0,1]" (and target":"ub.t.id" yields #[0,0] instead of t.id), although node 1/2 carry cast((cast(t.v AS BIGINT) + 1) AS INT) and t.v + 1.
Expected Behavior
node.assignments[*].value must be the resolved row-image expression, exactly as the design document states. Concretely:
update t set v = 2 where id = 1->{"target":"ub.t.id","value":"t.id"}, {"target":"ub.t.v","value":"2"}.update t set v = v + 1 where id = 1->{"target":"ub.t.v","value":"t.v + 1"}(or the equivalent typed expression actually projected).
MySQL 8.0 reports "set": {"t.v": "2"} for the same statements; MatrixOne must not emit #[rel,col] placeholder refs it has already resolved elsewhere in the same document.
Steps to Reproduce
drop database if exists ub; create database ub; use ub;
create table t(id int primary key, v int);
insert into t values (1,10);
explain format=json update t set v = 2 where id = 1;Inspect the Multi Update node's assignments: both values are #[0,0] / #[0,1] rather than t.id / 2. Repeated three times and via a prepared statement (prepare s from 'explain format=json update t set v = 2 where id = 1') with identical output.
Additional information
Root cause is sqlJSONPlanBuilder.resolveUpdateColumnExpr in pkg/sql/plan/explain/sql_json.go. For a MULTI_UPDATE the row image is read from UpdateCtxList.InsertCols and resolved through only the immediate child: when ref.RelPos == 0 it returns child.ProjectList[ref.ColPos] verbatim (no further resolution). A real UPDATE plan places a Lock Operator between the MULTI_UPDATE and the producing Project; the Lock Operator's ProjectList is a passthrough of column refs (["#[0,0]","#[0,1]","#[0,2]","#[0,3]"]), so the resolver returns a column-ref expression and sqlJSONExpr serializes it as the literal #[0,1] string. The genuine value in the underlying Project is never consulted.
This gap is not caught by the newly added tests because TestBuildSQLJSONPlanResolvesPrunedUpdateAssignments (pkg/sql/plan/explain/sql_json_test.go:346) builds a LOCK_OP child whose ProjectList holds literal values (sqlJSONTestInt32(...)) rather than the passthrough column refs a real plan uses, so the single-level lookup happens to resolve to a real value there.
Impact: EXPLAIN FORMAT=JSON is the only way to inspect UPDATE assignments, and it is unusable/misleading for every real UPDATE (constant, expression, and unchanged columns alike). No data is corrupted; ordinary text EXPLAIN is unaffected, so the workaround is to avoid/ignore the assignments field. Severity is therefore major (incorrect documented EXPLAIN output with a workaround) rather than critical.
Note: #28301 tracks the feature being unavailable before #28435; that is not this issue. #30108 tracks the retired vector-scan protobuf build break, also unrelated.
Found by Loom bug hunt (module: sql-plan; tests: end-to-end)
Activity
fix(explain): resolve JSON UPDATE assignment expressions (#30139)
slyunnn commentedon Oct 16, 2026
Regression and extended verification for #30130 (2026-10-16)
Verification Environment
origin/main:b24d1b311555e0b6f3d56eb37f9a2e9617e9a5b7—fix(window): support temporal interval frame parameters and string parsing (#30310). The runningmo-service -versionreported this exact commit, and the Log, TN, both CNs, and Proxy process executables had the same SHA-256 checksum.66e7a4cf0ba25747e2071faef5d971654fca20e9—fix(explain): resolve JSON UPDATE assignment expressions. This commit is an ancestor of the testedmain.2 CN / 1 TN / 1 Log service / 1 Proxy. Direct test endpoints inside the isolated network were Proxymo-proxy:6001, CN1mo-cn1:16001, and CN2mo-cn2:16002; all were reachable. The isolated Proxy was also mapped to a nondefault host port because the shared host port6001belongs to another cluster.8.4CLI over the native MySQL text protocol withutf8mb4; SQLPREPARE/EXECUTEwas used for the prepared case. Additional host-mapped checks used MySQL CLI9.7.1.What Was Covered
EXPLAIN FORMAT=JSON UPDATE t SET v=2 WHERE id=1scenario, using an isolated schema:assignmentsrendered unchangedidast.idand assignedvas2, rather than raw#[rel,col]references, through Proxy, CN1, and CN2.v=v+1,v=NULL,v=id*10, and aWHEREpredicate matching no rows rendered their intended expressions. The literal, arithmetic, andNULLcases were also rerun through all three exact service ports.PREPARE/EXECUTEof JSONEXPLAINrendered assigned value7through all three exact service ports.UPDATEdisplayed lineage for both targets and the assigned99/88values through all three exact service ports. AdditionalEXISTSand nullableINsubquery assignment checks rendered readable source expressions on the same exact-main cluster.1054/42S22on all three exact service ports; subsequent queries succeeded.EXPLAINdid not modify either table. A realUPDATEchangedvfrom10to2as a control and was then restored to10; ordinary textEXPLAINremained usable.COM_STMT_PREPARE/COM_STMT_EXECUTEand a full BVT-suite replay. This issue concerns JSON plan rendering, not the binary prepared protocol; its focused SQL-prepared and direct-protocol cases passed.Findings
The merged fix resolves
UPDATErow-image references through the producing plan nodes before renderingassignments. No unresolved#[rel,col]value appeared in the checked assignment paths. The defect affected explanation output, notUPDATEdata correctness.MOTR / BVT Coverage
test/distributed/cases/optimizer/explain_format_json.sqland its.result; focused resolver tests are inpkg/sql/plan/explain/sql_json_test.go.pkg/sql/plan/explainGo tests covering plannerUPDATEassignments, multi-target assignments, MARK/subquery outputs, and resolver boundaries passed on the tested main commit.Final Conclusion
Fixed on latest
origin/mainb24d1b311555e0b6f3d56eb37f9a2e9617e9a5b7for the original scenario and the tested extensions across the2 CN / 1 TN / 1 Log service / 1 Proxytopology.Large-data regression: not needed. The bug is in deterministic JSON plan-expression resolution during
EXPLAIN, not a row-count, block/batch, memory/spill, concurrency, network-transfer, or resource-scale boundary. Small isolated tables exercise the affected plan shapes without unrelated CI cost.