Bug #30263 soundex function returns incorrect values in some cases
Submitted: 7 Aug 2007 2:20 Modified: 8 Aug 2007 5:03
Reporter: Lindsay Patten Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version:5.0.45-community-nt OS:Any
Assigned to: CPU Architecture:Any

[7 Aug 2007 2:20] Lindsay Patten
Description:
The values returned by soundex(String) do not conform to the correct values for some strings.  For example, soundex('Mannon') returns 'M000' but should return 'M550'. The soundex algorithm ignores a character if it has the same code as the previous character and vowels do not output a code, but a character that follows a vowel is not treated the same as a character that is a repeat. The first 'n' in Mannon follows an 'a' so it should generate a code of 5. The second 'n' follows directly after the first so it is ignored, but the final 'n' follows an 'o' so it also should generate a code.
Mnnn would generate M000 but Mannon should generate M550.
You likely fail to reset the variable storing the last code when you process a vowel character, but I have not looked at your code.

How to repeat:
select soundex('Mannon');

Suggested fix:
Correct the soundex function.
[7 Aug 2007 7:07] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.

P.S. On Oracle, for example, one will get:

SQL> select soundex('Mannon'), soundex('Mnnn') from dual;

SOUN SOUN
---- ----
M550 M000
[7 Aug 2007 12:07] Sergei Golubchik
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_soundex
"
  Note: This function implements the original Soundex algorithm,
  not the more popular enhanced version (also described by D. Knuth).
  The difference is that original version discards vowels first and
  duplicates second, whereas the enhanced version discards duplicates
  first and vowels second.
"
[7 Aug 2007 13:14] Lindsay Patten
Please implement a second version of soundex that is compatible with 99% of the other implementations, not the obsolete and deeply flawed original version.
[8 Aug 2007 5:03] Valeriy Kravchuk
Sorry, if not a bug formally, this is a reasonable feature request anyway.