Repository navigation
Conversation
ffb2b21 to
2ded0e2
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 9a581373a942617ad536d8ecd3c5556c50b0d2ac: request changes for one concrete string-domain correctness blocker.
[P1] Select binary rejection using the evaluated row's domain, not only the vector's static type
pkg/sql/plan/function/func_unary.go:1100-1104 chooses the binary-error callback once using types.StaticStringDomain. That is not the complete domain contract in current main: vector.GetIsBinaryStringAt(row) combines static type, runtime binary provenance and explicit text overrides.
Concrete input: a VARCHAR vector containing non-NULL bytes plain with runtime binary provenance. The static check is false, and the new passthrough at lines 1111-1112 returns plain successfully. A static VARBINARY containing the same binary value instead raises the intended binary-domain error. This is a reachable evaluator state, not a fabricated flag: ParamExpressionExecutor.Eval publishes GetPrepareParamIsBinaryString onto the result at pkg/sql/colexec/evalExpression.go:623; the user-variable evaluator does likewise at line 781. CASE/IF selected-row propagation is already tested by TestFlowControlPreservesSelectedBinaryStringRows, which produces a VARCHAR result with different binary/text domains per row.
The converse also matters: TestFlowControlPromotesSelectedStaticTextUnderBinaryResult covers a statically VARBINARY result whose selected value has an explicit text override. The new batch-wide callback rejects that text row, although the canonical row-aware API identifies it as text. Consequently the result/error can change across prepared parameter binding or flow-control materialization rather than following the selected value's semantics.
Please perform the domain check inside a row-aware evaluator, after NULL and select-list suppression, using GetIsBinaryStringAt(row). Preserve the typed-JSON branch and always publish text output metadata. Do not use a mutable callback counter, because the current unary template skips NULL/masked rows and evaluates a constant only once. Add mixed binary/text vectors (including a text override under static binary type), inactive binary branches, NULLs, and prepared text→binary→text rebinds. No SetIsBin shortcut is appropriate here.
Other reviewed aspects: first/last-byte quote framing preserves ordinary SQL text; malformed fully framed strings still parse/error; UTF-8 validation is explicit; CHAR/VARCHAR/TEXT capacity and utf8mb4_bin result metadata are preserved; numeric/date inputs are rejected before generic casts; allocation errors retain existing wrapper propagation. No separate resource-lifetime, concurrency or production-performance blocker was found. The UTF-8 check adds a linear scan but the passthrough avoids JSON parsing/materialization for ordinary text.
Evidence: exact-head source/type-matcher/template inspection and the existing runtime-domain producer/test contracts, plus the author's exact-head package/CTAS validation. I did not claim a fresh native SQL or MySQL reproduction. git diff --check passes; CI was not awaited. This is a value/error correctness issue, not a request to block solely on absent tests.
|
Addressed XuPeng-SH's exact-head finding on
Validation on the exact pushed commit:
The pushed commit is ready for re-review. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed exact head b28269ef909fe1407fe4e5e1a5bd761769af8804. The previous row-domain blocker is closed; no further confirmed blocking issue found.
The new row-aware unary evaluator passes the actual row index, rather than a callback counter. NULL and inactive rows are suppressed before JSON_UNQUOTE's domain check; constant values retain one evaluation. GetIsBinaryStringAt(row) now handles both runtime binary provenance on VARCHAR and explicit selected-text overrides under a binary static type. The mixed-domain/masked-row fixtures and actual packet-decoder → rebind → expression-executor text/binary/text test address the previously demonstrated production paths, including cached-plan immutability and recovery after an error.
I checked the full diff, matcher and result typing, unary-template compatibility, and text versus typed-JSON paths. Ordinary UTF-8 SQL text is preserved without JSON canonicalization; only fully quote-framed text enters JSON parsing, preserving malformed-framed-input errors. Typed JSON still uses its existing decoding/unquote path. CHAR/VARCHAR/TEXT bounds and utf8mb4_bin result metadata are covered by function and CTAS tests; binary NULL propagates and non-NULL binary values fail at evaluation.
The shared wrapper preserves the previous callers' callback semantics. UTF-8 validation adds a linear scan, but ordinary text avoids JSON parsing/materialization; no new persistent cache, asynchronous ownership, or unbounded lifecycle state is introduced. No concrete new performance or resource blocker identified.
Validation in this round: complete source/diff and test inspection, prior runtime-domain evidence, and git diff --check. I did not freshly run native UT/BVT, race, or a live MySQL differential test and did not wait for CI. The protocol fixture tests packet decoding and real expression execution, not a complete client/server handshake.
Merge Queue Status
This pull request spent 3 minutes 38 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28090 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 #28042
What this PR does / why we need it:
JSON_UNQUOTEtreats SQL text as a JSON string only when the first and last bytes are both double quotes. Ordinary text, JSON-looking object/array/number text, one-sided quotes, and text with outer whitespace are returned unchanged. Fully quote-framed malformed strings and invalid UTF-8 still return errors, while typed JSON input keeps its canonical unquote behavior.The result keeps the source CHAR/VARCHAR/TEXT capacity, including MEDIUMTEXT and LONGTEXT bounds, and always publishes
utf8mb4_binresult metadata. CTAS therefore preserves both the source capacity and binary collation identity. Non-string scalar inputs such as DATE/TIME/numeric values are rejected before generic string casts can enter the passthrough path.Binary domains remain visible through binding so NULL propagates as SQL NULL. Non-NULL BINARY, VARBINARY, BLOB, and binary-charset values reach execution and return the binary-domain error.
This head is based on
upstream/main4fdb9e91615f9fc37703039ae28a47849206d1d6, which includes #28089.Validation on exact head
9a581373a942617ad536d8ecd3c5556c50b0d2ac:.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run 'TestJsonUnquote' ./pkg/sql/plan/function.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run 'TestBuildCTASPreservesJsonUnquoteTextBounds' ./pkg/sql/planpkg/sql/plan/functionandpkg/sql/planthroughmo-cgo-testmake buildtest/distributed/cases/function/func_json_unquote.sqland.resultupdated for these cases. Local mo-tester execution is pending because this macOS host has no Java runtime; exact-head CI must supply the public-path BVT evidence.git diff --check: PASSmo-self-review: PASSPASS semantic=PASS; diff hasha44f95565f5343965d3ab3e469d4eb451591b93c07ef2714e7847ec18923f99fQA Required: yes. The SQL value, protocol metadata, domain-error, and CTAS contracts require fresh exact-head CI/BVT and QA verification before merge.