Repository navigation
fix(json): preserve MySQL binary subtype fidelity - #28092
Conversation
1dea66f to
238ed53
Compare
238ed53 to
2c10567
Compare
|
Rebased/merged current Current exact head: |
|
The first post-conflict UT result is an external runner failure, not a source/test assertion. Job |
af834f7 to
49e05f7
Compare
|
Addressed XuPeng-SH's two blocking findings on exact head
Focused ByteJson/vector/defines/keycodec tests, build, vet, diff-check, semantic preflight, and final self-review pass. The CGo-transitive No inline review threads were present to resolve. Please re-review this exact head. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 49e05f7745f8890c3c1630900b2d8b7042e2168d.
The previous mixed-version admission and normal tagged-payload hot-path findings are substantially closed: construction now requires v50 admission, same-subtype compare decodes once without allocation, and TYPE validates without materializing the payload.
[P1] Restore comparison/canonical-key equivalence for malformed-tag fallback
The new forceRaw branch in compareBinaryJSONValues compares both operands through binaryJSONFallbackBytes. For a valid tagged peer, that helper returns the complete stored base64:typeN:... text, while canonicalization decodes that peer to its payload. This creates values that compare unequal but have identical resident/spill keys.
Concrete counterexample at the ByteJson boundary:
A = TpCodeBlob("base64:type16:not-base64"). The tag payload is malformed, so the promised fail-closed interpretation is a raw BLOB whose bytes are the full string.B = NewMySQLOpaque(v50, 252, []byte("base64:type16:not-base64")). This is a valid tagged BLOB whose decoded payload is exactly As fallback bytes.AppendCanonicalBinary(A)andAppendCanonicalBinary(B)both producemarker || type252 || "base64:type16:not-base64".CompareBinaryJSON(A, B)resolves A toforceRaw, then compares As raw bytes with Bs completebase64:type252:...storage text and returns non-zero.
That violates the key invariant used by GROUP BY, DISTINCT, hash join/routing, and spill: scalar equality and canonical equality must define the same equivalence relation. It also means the PR-body claim that malformed tags fail closed consistently across comparison and canonicalization is not yet true.
Please represent a malformed value after resolution as an ordinary raw BLOB payload (rather than forcing both peers into storage-text comparison), so a valid encoded peer is still compared through its decoded payload. Add bidirectional tests asserting sign(compare) == key equality for malformed type16/type252 tags against valid tagged BLOBs carrying the fallback bytes, plus malformed legacy bare-Base64 and nested/hash-key coverage. Keep the fixed valid-payload fast path allocation-free.
Delivery note: v50 is also allocated by other open PRs; after this fix, rebase on the then-current main and retain a unique latest protocol allocation.
|
Addressed the current-head malformed-tag equivalence finding in
Validation: full Please re-review this exact Ready head. |
|
Follow-up for the current head
Please review the current head, especially the v52 allocation and malformed-tag comparison/canonical-key equivalence. |
There was a problem hiding this comment.
Deep review completed against current head e348620.
The two previously blocking concerns are closed:
- mixed-version behavior is gated behind a unique MORPC protocol version while legacy readers retain the historical type-code path;
- malformed tag handling now preserves comparison and canonical-key equivalence.
Counterexample review covered malformed and valid tag pairs, raw BLOB fallback, mixed-version admission, empty payloads, large payloads, canonical-key consistency, and comparison/TYPE allocation behavior. I found no remaining correctness, compatibility, unhappy-path, or material performance blocker.
The head changed during review because main was merged. I verified that the old-base/old-head and new-base/new-head diffs have the same stable patch-id bacde14285c9221095956c773e34eb3084241402. The only direct old-head/new-head differences are main-side test updates, so the reviewed PR semantics are unchanged.
Local execution is blocked by the known macOS CGo prerequisite absence: cgo/libmo.dylib is not available in the isolated worktree. This is an environment prerequisite failure rather than a test assertion failure.
Merge Queue Status
This pull request spent 13 minutes 28 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28092 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:
issue #28057
issue #28058
What this PR does / why we need it:
Preserves MySQL binary subtypes and raw payload bytes in ByteJson without adding a persistent type code. BINARY, VARBINARY, and BLOB use legacy-readable
TpCodeBlobvalues containingbase64:typeNpayloads. New readers accept legacy bare Base64, the prior BIT sentinel, and the new tags.This update adds the rolling-upgrade admission contract before tagged values are produced:
NewMySQLOpaquerequires the minimum admitted MORPC version (MORPCVersion50, following the target's v46-v49 prefix) and rejects older writers before constructing tagged payloads. The stacked SQL constructor PR must pass that explicit admission value.Tagged payload recognition now parses only the bounded
typeN:header. Valid tagged terminal operations validate or decode the payload at most once;TYPEdoes not materialize the payload. Malformed tags fail closed as raw BLOB bytes across type inspection, comparison, payload length, and canonicalization.QA required: yes — this is the storage/representation foundation for a compatibility stack and issues remain open until exact-version QA completes.
Production terminal covered by automation: ByteJson root/nested marshal, vector storage, merge, comparison/hash, payload length, legacy-reader compatibility, rolling-upgrade admission, malformed-tag fallback, and existing CAST constant folding.
Remaining QA
Mixed-version disk reads and the full constructor SQL surface remain covered by the stacked PRs and tester handoff. The local CGo-transitive
pkg/sql/plan/functioncheck must be rerun when the nativecgo/libmo.dylibprerequisite is available; the direct bytejson/vector/defines/keycodec validation is green.Validation:
go testfor./pkg/container/bytejson: PASS, including admission rejection/acceptance, legacy/sentinel compatibility, malformed fallback, and 1 MiB allocation checks.go testfor./pkg/container/vector,./pkg/defines, and./pkg/common/hashmap/keycodec: PASS.go vet: PASS.git diff --check: PASS.mo-cgo-testfor./pkg/sql/plan/function: BLOCKED — the isolated environment lackscgo/libmo.dyliband the native third-party prerequisite; no test assertion failed.