Re: Fuzzy substring searching with the pg_trgm extension

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fuzzy substring searching with the pg_trgm extension
Date: 2016-01-12 09:36:20
Message-ID: 5694C914.8030103@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> ! float4 tmpsml = cnt_sml(qtrg, key, *recheck);
>>
>> /* strange bug at freebsd 5.2.1 and gcc 3.3.3 */
>> ! res = (*(int *) &tmpsml == *(int *) &nlimit || tmpsml > nlimit) ? true : false;
>
> What's the compiler bug about? This code and comment were introduced in
> cbfa4092bb (May 2004) without any explanation. Do we still need to keep
> it, if &nlimit is now a local variable instead of a global? FWIW the
> oldest GCC in the buildfarm is 3.4.2/3.4.3 (except for Gaur which uses

As I remeber, the problem was with x87 math coprocessor. Compiler (suppose,
modern compiler could do it too) keeps tmpsml in internal 80-bit wide register
and compares with 32-bit wide float. Of course, it depends on level of
optimization and so, result of comparison was differ in optimization enabled and
disabled instances. Such strange way I choose to force compiler to use main
memory for tmpsml variable. Actually, I don't know better way even now.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2016-01-12 10:37:54 Re: Removing Functionally Dependent GROUP BY Columns
Previous Message Dilip Kumar 2016-01-12 09:11:47 Re: Relation extension scalability