Repository navigation
fix(function): preserve row-local FROM_BASE64 decoding semantics - #28360
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 of 7be48b340a2f8d53ea267f54cfb0aaf5c69dd41e, against main / merge-base 074bc173a5b64ed0ff0b6ad6ab091f478bf76c27.
No blocking findings. The change addresses #28208's decoded-length and whitespace failures, and correctly repairs row-local NULL/invalid handling and append-error propagation.
Reviewed all four delivery files, including a text diff of the binary-marked BVT result file, and traced function registration/evaluation, selection masks, result reset, byte copying and allocation-error cleanup. The MySQL byte-whitespace set agrees with the MySQL decoder. Invalid input discards partial decoded bytes; masked rows skip decoding; successful appends copy into result-owned storage before scratch is reused.
Fresh verification:
- Complete
pkg/sql/plan/functionsuite passed: 16.088s, exit 0, Darwin/arm64 CPU build with Go 1.26.4. - Additional temporary review probes passed: all 256 possible inserted bytes; changing payload contents and sizes across the 64-byte scratch boundary; large/short/empty/invalid rows in one batch; forced output-pool exhaustion, error propagation, reset/recovery and final pool cleanup. Final probe run: 1.751s, exit 0. These probes were removed from the worktree after validation.
- Existing benchmark passed with output validation and three samples. For 128 rows of ordinary 1 KiB input, allocation remained 1,248 B and two allocations per batch. Timing varied substantially on this shared host, so this review does not assert a new throughput comparison.
- Current-head GitHub checks show Linux UT, SCA, PROXY BVT and PESSIMISTIC BVT successful.
git diff --checkpassed.
Unhappy-path / performance assessment: no added waits, goroutines, synchronization, logging or cross-call retained state. Decode/fallback work is linear in the row's encoded size. Scratch capacity is call-local and proportional to the largest row processed, not a fixed memory ceiling; output storage remains subject to vector allocation checks. There is no reason to add distributed restart or repeated race suites for this scalar-local change.
Recommendation: acceptable to merge from this review. Submitting COMMENT because the authenticated account is the PR author; GitHub does not permit self-approval.
…rixorigin#28360) ## What type of PR is this? - [x] BUG - [x] Improvement - [x] Test and CI ## Which issue(s) this PR fixes: Fixes matrixorigin#28208 ## What this PR does / why we need it: Restore the row-local FROM_BASE64 contract: valid input returns exactly the decoded bytes, invalid/NULL input produces only that row's NULL, and masked rows are not evaluated. The old implementation ignored Decode's written-byte count, returned from the entire batch on NULL/invalid input, and discarded result-append errors. - Preserve the standard decoder fast path; on failure only, compact MySQL whitespace into separate scratch storage and retry once. Input vectors are never mutated. The whitespace byte set matches MySQL 8.0's `include/base64.h` table (space, 0x09–0x0d, 0xa0), not Unicode whitespace. - Use call-local bounded scratch: a small stack buffer, reused decoded storage for larger rows, and lazy whitespace scratch. No global state, cache, synchronization, or cross-batch retention. - Propagate result-append errors and discard partial decoded prefixes on invalid input. - Extend existing UT/BVT instead of introducing a cluster fixture. Correct three existing BVT expectations that embedded the erroneous trailing NUL bytes. Add explicit cleanup of tables previously left behind by the case. - Test mixed valid/NULL/invalid rows, padding, empty input/batch, binary bytes, whitespace classes, malformed padding, constant input, masked rows, input immutability, and result reuse. Keep a focused benchmark; the temporary legacy comparison implementation is not delivered. MySQL source reference: https://github.com/mysql/mysql-server/blob/8.0/include/base64.h ## Validation - Pre-fix regression: FAIL, expected 15 rows but got 3; the first NULL prematurely ended the batch. - Native CPU owning-package test: PASS, `mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function`. - `make -j8 build`: PASS. - SQL/BVT on the reviewed final binary: `func_encode_decode.sql` passed 124/124 twice on the same standalone instance (0.380s and 1.645s), with zero residual fixture tables between runs. SQL and ISCP readiness were checked before execution. - Local same-machine benchmark, 128 rows/batch: initial paired comparison used three 200ms samples; final reviewed candidate used three 300ms samples. 1KiB payload without whitespace improves from approximately 94us to 71us; allocations fall from 129 to 2 and bytes allocated from 147552 to approximately 1248 per batch. Short 12-byte payload is approximately 4.6us vs 4.2us (~7–10% / roughly 3ns per row) with the same allocation count. This is a microbenchmark, not an end-to-end SQL throughput claim. Legacy whitespace timings are excluded because the old implementation exited on the first row instead of decoding the batch. ## Review scope R2 public scalar result contract with focused hot-path benchmarking. Ordinary bug fix: no design-document gate. No persisted/wire format, transaction, shared state, or topology contract changes; distributed/race/restart suites are not substitutes for scalar UT and public SQL evidence here. Reviewed all four delivery files, including textual inspection of the binary-marked result file. Unrelated encoding/vector functions remain unchanged. Full pre-PR review traced registration/evaluation -> function -> result append -> owned varlena storage. It found and fixed an all-masked-row gap: `FunctionSelectList.Contains` does not encode `AllNull`. The initial test derived its expectation from the same helper and therefore missed it. Replacing that oracle with explicit NULL expectations produced a deterministic failure; the implementation now honors `IgnoreAllRow` explicitly. The aliasing test crosses non-inline storage boundaries. Benchmarks validate every output before timing, preventing early termination/NULL output from masquerading as throughput. Reviewed delivery head: `34c5158f18b2432a5de1c10db11c6a6f3d8803fc`; base/merge-base: `df261604fe207e592f5d92b15d66167c38e97db6`. Main subsequently advanced only through matrixorigin#28345 (sequence code), without overlap with this closure. No unresolved in-scope review blockers. Local service logs also contain ISCP transaction-finish timeouts; those background warnings are not claimed resolved by this scalar-function PR. All selected public SQL checks completed successfully. CI has not been waited for. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…rixorigin#28360) ## What type of PR is this? - [x] BUG - [x] Improvement - [x] Test and CI ## Which issue(s) this PR fixes: Fixes matrixorigin#28208 ## What this PR does / why we need it: Restore the row-local FROM_BASE64 contract: valid input returns exactly the decoded bytes, invalid/NULL input produces only that row's NULL, and masked rows are not evaluated. The old implementation ignored Decode's written-byte count, returned from the entire batch on NULL/invalid input, and discarded result-append errors. - Preserve the standard decoder fast path; on failure only, compact MySQL whitespace into separate scratch storage and retry once. Input vectors are never mutated. The whitespace byte set matches MySQL 8.0's `include/base64.h` table (space, 0x09–0x0d, 0xa0), not Unicode whitespace. - Use call-local bounded scratch: a small stack buffer, reused decoded storage for larger rows, and lazy whitespace scratch. No global state, cache, synchronization, or cross-batch retention. - Propagate result-append errors and discard partial decoded prefixes on invalid input. - Extend existing UT/BVT instead of introducing a cluster fixture. Correct three existing BVT expectations that embedded the erroneous trailing NUL bytes. Add explicit cleanup of tables previously left behind by the case. - Test mixed valid/NULL/invalid rows, padding, empty input/batch, binary bytes, whitespace classes, malformed padding, constant input, masked rows, input immutability, and result reuse. Keep a focused benchmark; the temporary legacy comparison implementation is not delivered. MySQL source reference: https://github.com/mysql/mysql-server/blob/8.0/include/base64.h ## Validation - Pre-fix regression: FAIL, expected 15 rows but got 3; the first NULL prematurely ended the batch. - Native CPU owning-package test: PASS, `mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function`. - `make -j8 build`: PASS. - SQL/BVT on the reviewed final binary: `func_encode_decode.sql` passed 124/124 twice on the same standalone instance (0.380s and 1.645s), with zero residual fixture tables between runs. SQL and ISCP readiness were checked before execution. - Local same-machine benchmark, 128 rows/batch: initial paired comparison used three 200ms samples; final reviewed candidate used three 300ms samples. 1KiB payload without whitespace improves from approximately 94us to 71us; allocations fall from 129 to 2 and bytes allocated from 147552 to approximately 1248 per batch. Short 12-byte payload is approximately 4.6us vs 4.2us (~7–10% / roughly 3ns per row) with the same allocation count. This is a microbenchmark, not an end-to-end SQL throughput claim. Legacy whitespace timings are excluded because the old implementation exited on the first row instead of decoding the batch. ## Review scope R2 public scalar result contract with focused hot-path benchmarking. Ordinary bug fix: no design-document gate. No persisted/wire format, transaction, shared state, or topology contract changes; distributed/race/restart suites are not substitutes for scalar UT and public SQL evidence here. Reviewed all four delivery files, including textual inspection of the binary-marked result file. Unrelated encoding/vector functions remain unchanged. Full pre-PR review traced registration/evaluation -> function -> result append -> owned varlena storage. It found and fixed an all-masked-row gap: `FunctionSelectList.Contains` does not encode `AllNull`. The initial test derived its expectation from the same helper and therefore missed it. Replacing that oracle with explicit NULL expectations produced a deterministic failure; the implementation now honors `IgnoreAllRow` explicitly. The aliasing test crosses non-inline storage boundaries. Benchmarks validate every output before timing, preventing early termination/NULL output from masquerading as throughput. Reviewed delivery head: `34c5158f18b2432a5de1c10db11c6a6f3d8803fc`; base/merge-base: `df261604fe207e592f5d92b15d66167c38e97db6`. Main subsequently advanced only through matrixorigin#28345 (sequence code), without overlap with this closure. No unresolved in-scope review blockers. Local service logs also contain ISCP transaction-finish timeouts; those background warnings are not claimed resolved by this scalar-function PR. All selected public SQL checks completed successfully. CI has not been waited for. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…rixorigin#28360) ## What type of PR is this? - [x] BUG - [x] Improvement - [x] Test and CI ## Which issue(s) this PR fixes: Fixes matrixorigin#28208 ## What this PR does / why we need it: Restore the row-local FROM_BASE64 contract: valid input returns exactly the decoded bytes, invalid/NULL input produces only that row's NULL, and masked rows are not evaluated. The old implementation ignored Decode's written-byte count, returned from the entire batch on NULL/invalid input, and discarded result-append errors. - Preserve the standard decoder fast path; on failure only, compact MySQL whitespace into separate scratch storage and retry once. Input vectors are never mutated. The whitespace byte set matches MySQL 8.0's `include/base64.h` table (space, 0x09–0x0d, 0xa0), not Unicode whitespace. - Use call-local bounded scratch: a small stack buffer, reused decoded storage for larger rows, and lazy whitespace scratch. No global state, cache, synchronization, or cross-batch retention. - Propagate result-append errors and discard partial decoded prefixes on invalid input. - Extend existing UT/BVT instead of introducing a cluster fixture. Correct three existing BVT expectations that embedded the erroneous trailing NUL bytes. Add explicit cleanup of tables previously left behind by the case. - Test mixed valid/NULL/invalid rows, padding, empty input/batch, binary bytes, whitespace classes, malformed padding, constant input, masked rows, input immutability, and result reuse. Keep a focused benchmark; the temporary legacy comparison implementation is not delivered. MySQL source reference: https://github.com/mysql/mysql-server/blob/8.0/include/base64.h ## Validation - Pre-fix regression: FAIL, expected 15 rows but got 3; the first NULL prematurely ended the batch. - Native CPU owning-package test: PASS, `mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function`. - `make -j8 build`: PASS. - SQL/BVT on the reviewed final binary: `func_encode_decode.sql` passed 124/124 twice on the same standalone instance (0.380s and 1.645s), with zero residual fixture tables between runs. SQL and ISCP readiness were checked before execution. - Local same-machine benchmark, 128 rows/batch: initial paired comparison used three 200ms samples; final reviewed candidate used three 300ms samples. 1KiB payload without whitespace improves from approximately 94us to 71us; allocations fall from 129 to 2 and bytes allocated from 147552 to approximately 1248 per batch. Short 12-byte payload is approximately 4.6us vs 4.2us (~7–10% / roughly 3ns per row) with the same allocation count. This is a microbenchmark, not an end-to-end SQL throughput claim. Legacy whitespace timings are excluded because the old implementation exited on the first row instead of decoding the batch. ## Review scope R2 public scalar result contract with focused hot-path benchmarking. Ordinary bug fix: no design-document gate. No persisted/wire format, transaction, shared state, or topology contract changes; distributed/race/restart suites are not substitutes for scalar UT and public SQL evidence here. Reviewed all four delivery files, including textual inspection of the binary-marked result file. Unrelated encoding/vector functions remain unchanged. Full pre-PR review traced registration/evaluation -> function -> result append -> owned varlena storage. It found and fixed an all-masked-row gap: `FunctionSelectList.Contains` does not encode `AllNull`. The initial test derived its expectation from the same helper and therefore missed it. Replacing that oracle with explicit NULL expectations produced a deterministic failure; the implementation now honors `IgnoreAllRow` explicitly. The aliasing test crosses non-inline storage boundaries. Benchmarks validate every output before timing, preventing early termination/NULL output from masquerading as throughput. Reviewed delivery head: `34c5158f18b2432a5de1c10db11c6a6f3d8803fc`; base/merge-base: `df261604fe207e592f5d92b15d66167c38e97db6`. Main subsequently advanced only through matrixorigin#28345 (sequence code), without overlap with this closure. No unresolved in-scope review blockers. Local service logs also contain ISCP transaction-finish timeouts; those background warnings are not claimed resolved by this scalar-function PR. All selected public SQL checks completed successfully. CI has not been waited for. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28208
What this PR does / why we need it:
Restore the row-local FROM_BASE64 contract: valid input returns exactly the decoded bytes, invalid/NULL input produces only that row's NULL, and masked rows are not evaluated. The old implementation ignored Decode's written-byte count, returned from the entire batch on NULL/invalid input, and discarded result-append errors.
include/base64.htable (space, 0x09–0x0d, 0xa0), not Unicode whitespace.MySQL source reference: https://github.com/mysql/mysql-server/blob/8.0/include/base64.h
Validation
mo-cgo-test -count=1 -timeout=10m ./pkg/sql/plan/function.make -j8 build: PASS.func_encode_decode.sqlpassed 124/124 twice on the same standalone instance (0.380s and 1.645s), with zero residual fixture tables between runs. SQL and ISCP readiness were checked before execution.Review scope
R2 public scalar result contract with focused hot-path benchmarking. Ordinary bug fix: no design-document gate. No persisted/wire format, transaction, shared state, or topology contract changes; distributed/race/restart suites are not substitutes for scalar UT and public SQL evidence here. Reviewed all four delivery files, including textual inspection of the binary-marked result file. Unrelated encoding/vector functions remain unchanged.
Full pre-PR review traced registration/evaluation -> function -> result append -> owned varlena storage. It found and fixed an all-masked-row gap:
FunctionSelectList.Containsdoes not encodeAllNull. The initial test derived its expectation from the same helper and therefore missed it. Replacing that oracle with explicit NULL expectations produced a deterministic failure; the implementation now honorsIgnoreAllRowexplicitly. The aliasing test crosses non-inline storage boundaries. Benchmarks validate every output before timing, preventing early termination/NULL output from masquerading as throughput.Reviewed delivery head:
34c5158f18b2432a5de1c10db11c6a6f3d8803fc; base/merge-base:df261604fe207e592f5d92b15d66167c38e97db6. Main subsequently advanced only through #28345 (sequence code), without overlap with this closure. No unresolved in-scope review blockers. Local service logs also contain ISCP transaction-finish timeouts; those background warnings are not claimed resolved by this scalar-function PR. All selected public SQL checks completed successfully. CI has not been waited for.