Re: BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit
Date
Msg-id 12708.1466432117@sss.pgh.pa.us
Whole thread Raw
In response to BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit  (contact@gregnavis.com)
List pgsql-bugs
contact@gregnavis.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

pgsql-bugs by date:

Previous
From: contact@gregnavis.com
Date:
Subject: BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit
Next
From: Jim Michaels
Date:
Subject: about and feature matrix on site