mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
fuzzystrmatch's difference() function assumes that _soundex() always initializes its output buffer fully. This was not so for the case of a string containing no alphabetic characters, resulting in unstable output and Valgrind complaints. Fix by using memset() to fill the whole buffer in the early-exit case. Also make some cosmetic improvements (I didn't care for the random switches between "instr[0]" and "*instr" notation). Report and diagnosis by Alexander Lakhin (bug #17935). Back-patch to all supported branches. Discussion: https://postgr.es/m/17935-b99316aa79c18513@postgresql.org
23 lines
629 B
SQL
23 lines
629 B
SQL
CREATE EXTENSION fuzzystrmatch;
|
|
|
|
|
|
SELECT soundex('hello world!');
|
|
|
|
SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann');
|
|
SELECT soundex('Anne'), soundex('Andrew'), difference('Anne', 'Andrew');
|
|
SELECT soundex('Anne'), soundex('Margaret'), difference('Anne', 'Margaret');
|
|
SELECT soundex(''), difference('', '');
|
|
|
|
|
|
SELECT levenshtein('GUMBO', 'GAMBOL');
|
|
SELECT levenshtein('GUMBO', 'GAMBOL', 2, 1, 1);
|
|
SELECT levenshtein_less_equal('extensive', 'exhaustive', 2);
|
|
SELECT levenshtein_less_equal('extensive', 'exhaustive', 4);
|
|
|
|
|
|
SELECT metaphone('GUMBO', 4);
|
|
|
|
|
|
SELECT dmetaphone('gumbo');
|
|
SELECT dmetaphone_alt('gumbo');
|