pgsql: Fix contrib/pg_trgm's similarity() function for trigram-free str - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix contrib/pg_trgm's similarity() function for trigram-free str
Date
Msg-id E1U5hgS-0005bk-QC@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9728eda7925b6d42621b38c48e91ef9ab8d90cbc

Modified Files
--------------
contrib/pg_trgm/expected/pg_trgm.out |    6 ++++++
contrib/pg_trgm/sql/pg_trgm.sql      |    2 ++
contrib/pg_trgm/trgm_op.c            |    8 ++++++--
3 files changed, 14 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix contrib/pg_trgm's similarity() function for trigram-free str
Next
From: Tom Lane
Date:
Subject: pgsql: Fix contrib/pg_trgm's similarity() function for trigram-free str