Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEzzd-00006S-Bv for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jun 2016 14:16:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bEzzc-0000c7-Un for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jun 2016 14:16:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bEzyz-0007rQ-Ie for pgsql-bugs@postgresql.org; Mon, 20 Jun 2016 14:15:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bEzyx-0006tU-1u for pgsql-bugs@postgresql.org; Mon, 20 Jun 2016 14:15:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u5KEFHVU012709; Mon, 20 Jun 2016 10:15:17 -0400 From: Tom Lane To: contact@gregnavis.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14202: pg_trgm: % uses incorrect comparison of similarity with the limit In-reply-to: <20160620115321.5792.10766@wrigleys.postgresql.org> References: <20160620115321.5792.10766@wrigleys.postgresql.org> Comments: In-reply-to contact@gregnavis.com message dated "Mon, 20 Jun 2016 11:53:21 -0000" Date: Mon, 20 Jun 2016 10:15:17 -0400 Message-ID: <12708.1466432117@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs