1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Fix contrib/pg_trgm's similarity() function for trigram-free strings.

Cases such as similarity('', '') produced a NaN result due to computing
0/0.  Per discussion, make it return zero instead.

This appears to be the basic cause of bug #7867 from Michele Baravalle,
although it remains unclear why her installation doesn't think Cyrillic
letters are letters.

Back-patch to all active branches.
This commit is contained in:
Tom Lane
2013-02-13 14:07:17 -05:00
parent 52c889ea4f
commit f73a16340c
3 changed files with 14 additions and 2 deletions

View File

@ -53,6 +53,12 @@ select similarity('wow',' WOW ');
1
(1 row)
select similarity('---', '####---');
similarity
------------
0
(1 row)
CREATE TABLE test_trgm(t text);
\copy test_trgm from 'data/trgm.data
select t,similarity(t,'qwertyu0988') as sml from test_trgm where t % 'qwertyu0988' order by sml desc, t;