Re: BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: contact(at)gregnavis(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit
Date: 2016-06-20 14:15:17
Message-ID: 12708.1466432117@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

contact(at)gregnavis(dot)com writes:
> Due to a bug gtrgm_consistent, using a GiST or GIN trigram index can return
> extraneous rows whose trigram-similarity was below set_limit().
> ...
> The root cause is this line in contrib/pg_trgm/trgm_gist.c:

> /* strange bug at freebsd 5.2.1 and gcc 3.3.3 */
> res = (*(int *) &tmpsml == *(int *) &nlimit || tmpsml > nlimit);

> nlimit is of type double. tmpsml is of type float4.

Ugh, yeah, that's completely broken now isn't it.

I suspect that changing tmpsml to double would be enough to get around the
alleged gcc bug and let us write the comparison naturally, ie the whole
thing was likely an artifact of using float4. Will try it that way.

Thanks for the report!

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jim Michaels 2016-06-20 15:23:55 about and feature matrix on site
Previous Message contact 2016-06-20 11:53:21 BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit