You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: SOUNDEX uses a fixed four-character algorithm unlike MySQL #28212
The same behavior occurs for column values and was reproduced three times.
Expected Behavior
SOUNDEX() must follow MySQL's enhanced Soundex result contract, including variable-length codes, first-letter duplicate suppression, and an empty result when no input character can seed a code.
SoundexString caps the builder at four bytes, pads every nonempty path to four bytes, returns 0000 when no ASCII letter exists, and initializes the previous digit to zero instead of the first letter's Soundex digit.
One terminology correction before implementation: the issue calls the target “enhanced Soundex”, but MySQL's manual says SOUNDEX() implements the original algorithm, not the enhanced variant: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html. The MySQL 8.3 examples recorded in this issue remain valid acceptance criteria; I will implement those actual outputs, including vowel/H/W discard-before-duplicate behavior, rather than follow the incorrect label.
Source trace confirms three concrete causes in SoundexString: output is capped at four characters, all nonempty results are padded to four (and no-letter input becomes 0000), and duplicate tracking starts at zero rather than the retained first letter's code. The current full-string Unicode uppercase also creates an avoidable copy; the focused fix will scan ASCII case-insensitively without introducing an unrelated Unicode/transliteration redesign.
The existing overloads return generic VARCHAR and the executor appends actual varlena lengths. I will add an executor/public-SQL control with a TEXT input whose result exceeds 65,535 bytes before considering any result-type metadata change.
No PR exists yet. The fix is being developed in an isolated branch; local CGo test execution remains subject to the previously recorded native-artifact provenance prerequisite, and will not be bypassed.
The implementation now suppresses a consonant code matching the first retained letter, preserves variable-length results, returns empty for empty/no-letter input, and pads only non-empty results shorter than four. It keeps the existing SQL wrapper and VARCHAR overload metadata. Tests cover issue examples, discarded-character duplicate behavior, NULL/empty/no-letter cases, vector/column/CHAR/prepared paths, capacity growth, and a 65,538-byte TEXT result.
Performance review rejected an exact-reservation optimization: it cut allocations for dense long output but slowed it, and nearly doubled CPU on a sparse 8,201-byte input with only nine output bytes and no allocation-count benefit. The submitted code uses one streaming pass and grows output only as codes are emitted.
Validation so far: formatting, diff checks, and incremental golangci-lint passed (0 issues). molint exited 0 with its existing diagnostic in unchanged byte_like_wildcard_search.go:17. Local Go UT/BVT were not run: the supported CGo wrapper is blocked by missing native-artifact provenance, and unrelated active MatrixOne services prevent safe local BVT. The PR's UT/BVT checks are pending; no runtime pass is claimed. The long SQL test checks exact server-side length/content, not a 65KB client result field. The change targets ASCII compatibility and does not add Unicode transliteration.
Activity
XuPeng-SH commentedon Sep 12, 2026
Design clarification for the fix
One terminology correction before implementation: the issue calls the target “enhanced Soundex”, but MySQL's manual says
SOUNDEX()implements the original algorithm, not the enhanced variant: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html. The MySQL 8.3 examples recorded in this issue remain valid acceptance criteria; I will implement those actual outputs, including vowel/H/W discard-before-duplicate behavior, rather than follow the incorrect label.Source trace confirms three concrete causes in
SoundexString: output is capped at four characters, all nonempty results are padded to four (and no-letter input becomes0000), and duplicate tracking starts at zero rather than the retained first letter's code. The current full-string Unicode uppercase also creates an avoidable copy; the focused fix will scan ASCII case-insensitively without introducing an unrelated Unicode/transliteration redesign.The existing overloads return generic VARCHAR and the executor appends actual varlena lengths. I will add an executor/public-SQL control with a TEXT input whose result exceeds 65,535 bytes before considering any result-type metadata change.
No PR exists yet. The fix is being developed in an isolated branch; local CGo test execution remains subject to the previously recorded native-artifact provenance prerequisite, and will not be bypassed.
XuPeng-SH commentedon Sep 12, 2026
Fix submitted: PR #28760
PR: #28760
Commit:
ba258866cc55d14ad34d19f2c3d14ff5f7a064cfThe fix follows the MySQL 8.3 outputs recorded above. One wording correction is important: MySQL documents
SOUNDEX()as the original Soundex algorithm, not the enhanced variant; the original algorithm discards vowels/code-zero characters before duplicate suppression. Reference: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_soundex.The implementation now suppresses a consonant code matching the first retained letter, preserves variable-length results, returns empty for empty/no-letter input, and pads only non-empty results shorter than four. It keeps the existing SQL wrapper and VARCHAR overload metadata. Tests cover issue examples, discarded-character duplicate behavior, NULL/empty/no-letter cases, vector/column/CHAR/prepared paths, capacity growth, and a 65,538-byte TEXT result.
Performance review rejected an exact-reservation optimization: it cut allocations for dense long output but slowed it, and nearly doubled CPU on a sparse 8,201-byte input with only nine output bytes and no allocation-count benefit. The submitted code uses one streaming pass and grows output only as codes are emitted.
Validation so far: formatting, diff checks, and incremental
golangci-lintpassed (0 issues).molintexited 0 with its existing diagnostic in unchangedbyte_like_wildcard_search.go:17. Local Go UT/BVT were not run: the supported CGo wrapper is blocked by missing native-artifact provenance, and unrelated active MatrixOne services prevent safe local BVT. The PR's UT/BVT checks are pending; no runtime pass is claimed. The long SQL test checks exact server-side length/content, not a 65KB client result field. The change targets ASCII compatibility and does not add Unicode transliteration.fix: align SOUNDEX with MySQL semantics (#28760)
Ariznawlll commentedon Sep 14, 2026
测试版本
原问题验证
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
回归测试
./motr --repeat 3 14_issue_regression.issue_28187_28772_latest_main连续 3/3 通过(213/213 statements matched)。测试证据
测试结论
测试通过。
fix: align SOUNDEX with MySQL semantics (matrixorigin#28760)
fix: align SOUNDEX with MySQL semantics (matrixorigin#28760)
fix: align SOUNDEX with MySQL semantics (matrixorigin#28760)