similarity() result for two trigram-less strings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: similarity() result for two trigram-less strings
Date: 2013-02-12 19:04:39
Message-ID: 26136.1360695879@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Some further thought about bug #7867 suggested that what's probably
happening is the submitter's installation doesn't think that any of the
Cyrillic letters are letters, so that no trigrams are identified in
either string. Whereupon you get a 0/0 result from cnt_sml:

regression=# select similarity('', '');
similarity
------------
NaN
(1 row)

What should we have it return instead? In this case "1" might seem like
the natural answer, but we could easily have very different strings that
don't contain any trigrams:

regression=# select similarity('---', '#######');
similarity
------------
NaN
(1 row)

Although I can see a case for returning 1, I'm inclined to think that
returning 0 is a better idea. Thoughts?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2013-02-12 19:17:50 Re: similarity() result for two trigram-less strings
Previous Message Boszormenyi Zoltan 2013-02-12 19:00:13 Re: Strange Windows problem, lock_timeout test request