Skip to content

fix(function): preserve wide strings in SHA2 - #28104

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
Lundomn:codex/issue-28103-sha2-longtext
Sep 4, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
Lundomn:codex/issue-28103-sha2-longtext

Conversation

@Lundomn

@Lundomn Lundomn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve MySQL string domains when resolving SHA2, avoiding implicit truncation to the 65535-byte VARCHAR limit
  • add unit coverage for LONGTEXT, MEDIUMTEXT boundary input, binary BLOB bytes, and SHA-224/256/384/512
  • add distributed SQL regression coverage for full-length and 65535-byte-prefix digest differences

Fixes #28103

Validation

  • gofmt passed
  • git diff --check passed
  • expected digests independently verified with Python standard library
  • focused Go test could not build in the current environment because required CGo/native headers and cgo/libmo.dylib are unavailable
  • distributed BVT was not run because mo-tester and a running service are unavailable

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review completed at exact head a4aae3c3178bc603df910c60cebdc79f60f4aa25 against current base/merge-base bf63172c0691e917ed2613c2d3a2d3d76a7f682e. I reviewed the complete four-file diff, SHA2 resolver and varlena execution path, all MySQL string domains, scalar implicit casts, NULL/invalid-algorithm behavior, binary-byte handling, and the distributed boundary regressions. The intervening merge of main preserves the reviewed patch byte-for-byte. Preserving the original CHAR/VARCHAR/TEXT/BINARY/VARBINARY/BLOB vector type is safe for GenerateFunctionStrParameter and removes the 65,535-byte VARCHAR cast boundary without changing the digest result type. No blocking issue found.

Validation on this exact head: git diff --check; full go test ./pkg/sql/plan/function -count=1; focused -race -run '^TestSHA2' -count=3; go vet ./pkg/sql/plan/function; and independent SHA-224/256/384/512 digest verification all passed with the required CGO/third-party setup.

@mergify

mergify Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review on exact head c9f901f: no blocking findings.\n\nI reviewed the complete six-file diff as two independent closures.\n\nSHA2 correctness and performance: changing only the resolver from fixedTypeMatch to stringDomainFixedTypeMatch preserves CHAR, VARCHAR, TEXT, BINARY, VARBINARY, and BLOB vectors instead of casting them through the 65,535-byte VARCHAR boundary. SHA2Func already consumes all of those domains as varlena bytes. Scalar-to-string casts, NULL and invalid-algorithm behavior, digest result type, and all SHA-224/256/384/512 branches remain unchanged. Counterexamples for 65,535 versus 65,536 bytes, 160,000-byte LONGTEXT, explicit TEXT casts, embedded NUL bytes, and CHAR padding close correctly. The hot path removes the intermediate cast/copy; hashing remains one O(input bytes) pass with no new per-row allocation attributable to this change.\n\nBVT and delivery: the SQL case is self-contained and uses the minimum values needed to cross the truncation boundary. Exact-head CI proves function_sha2.sql actually executed with 22/22 statements passing in 0.191s. The downloader change raises only the default attempt budget from 4 to 6; HTTPS-only transport, SHA-256 verification, byte limits, temporary-file cleanup, atomic installation, and environment overrides are unchanged. Cache-hit and normal successful downloads still make zero and one curl calls respectively. Persistent failure latency rises from roughly 8 to 12 minutes for the single pinned ONNX artifact, but remains bounded. Exact-head downloader contract tests passed on Ubuntu and macOS, including default budget, failure atomicity, concurrency, checksum, and size-limit cases.\n\nThe Go behavior and focused package/race evidence from the prior reviewed commit remain semantically valid because later commits only normalize the BVT result and adjust the shell downloader. Exact-head UT, SCA, native checks, BVT, and git diff --check are green. Current main is six commits ahead but does not touch any affected file.

@XuPeng-SH
XuPeng-SH merged commit a6f3988 into matrixorigin:main Sep 4, 2026
9 of 12 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- preserve MySQL string domains when resolving SHA2, avoiding implicit
truncation to the 65535-byte VARCHAR limit
- add unit coverage for LONGTEXT, MEDIUMTEXT boundary input, binary BLOB
bytes, and SHA-224/256/384/512
- add distributed SQL regression coverage for full-length and
65535-byte-prefix digest differences

Fixes matrixorigin#28103

## Validation

- gofmt passed
- git diff --check passed
- expected digests independently verified with Python standard library
- focused Go test could not build in the current environment because
required CGo/native headers and cgo/libmo.dylib are unavailable
- distributed BVT was not run because mo-tester and a running service
are unavailable

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- preserve MySQL string domains when resolving SHA2, avoiding implicit
truncation to the 65535-byte VARCHAR limit
- add unit coverage for LONGTEXT, MEDIUMTEXT boundary input, binary BLOB
bytes, and SHA-224/256/384/512
- add distributed SQL regression coverage for full-length and
65535-byte-prefix digest differences

Fixes matrixorigin#28103

## Validation

- gofmt passed
- git diff --check passed
- expected digests independently verified with Python standard library
- focused Go test could not build in the current environment because
required CGo/native headers and cgo/libmo.dylib are unavailable
- distributed BVT was not run because mo-tester and a running service
are unavailable

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- preserve MySQL string domains when resolving SHA2, avoiding implicit
truncation to the 65535-byte VARCHAR limit
- add unit coverage for LONGTEXT, MEDIUMTEXT boundary input, binary BLOB
bytes, and SHA-224/256/384/512
- add distributed SQL regression coverage for full-length and
65535-byte-prefix digest differences

Fixes matrixorigin#28103

## Validation

- gofmt passed
- git diff --check passed
- expected digests independently verified with Python standard library
- focused Go test could not build in the current environment because
required CGo/native headers and cgo/libmo.dylib are unavailable
- distributed BVT was not run because mo-tester and a running service
are unavailable

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SHA2 truncates LONGTEXT input to 65,535 bytes

4 participants