add soundex difference function to contrib/fuzzystrmatch

Lists: pgsql-patches
From: Kris Jurka <books(at)ejurka(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: add soundex difference function to contrib/fuzzystrmatch
Date: 2005-01-25 06:13:07
Message-ID: Pine.BSO.4.56.0501250110570.29918@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


The attached patch implements the soundex difference function which
compares two strings' soundex values for similarity.

http://databases.about.com/od/development/l/aasoundex.htm

Kris Jurka

Attachment Content-Type Size
soundex.difference.patch text/plain 4.8 KB

From: Neil Conway <neilc(at)samurai(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: add soundex difference function to
Date: 2005-01-25 07:05:52
Message-ID: 1106636752.9525.7.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Tue, 2005-01-25 at 01:13 -0500, Kris Jurka wrote:
> The attached patch implements the soundex difference function which
> compares two strings' soundex values for similarity.

*** 19,24 ****
--- 19,28 ----
AS 'MODULE_PATHNAME', 'soundex'
LANGUAGE 'C';

+ CREATE FUNCTION difference(text,text) RETURNS int
+ AS 'MODULE_PATHNAME', 'difference'
+ LANGUAGE 'C';
+

This should be immutable, right?

-Neil


From: Kris Jurka <books(at)ejurka(dot)com>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: add soundex difference function to contrib/fuzzystrmatch
Date: 2005-01-25 07:26:31
Message-ID: Pine.BSO.4.56.0501250214120.29396@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Tue, 25 Jan 2005, Neil Conway wrote:

> On Tue, 2005-01-25 at 01:13 -0500, Kris Jurka wrote:
> > The attached patch implements the soundex difference function which
> > compares two strings' soundex values for similarity.
>
> *** 19,24 ****
> --- 19,28 ----
> AS 'MODULE_PATHNAME', 'soundex'
> LANGUAGE 'C';
>
> + CREATE FUNCTION difference(text,text) RETURNS int
> + AS 'MODULE_PATHNAME', 'difference'
> + LANGUAGE 'C';
> +
>
> This should be immutable, right?
>

Yes, it should, and even more importantly strict because it crashes when
called with null inputs. I copied this off the adjacent entry without
thinking about it. So currently SELECT text_soundex(NULL); crashes the
server. I've attached two new patches. One revising my original patch to
make the function creations consistent and the other to just fix the
problem in the existing code (which should be backported as far as people
would like to).

Kris Jurka

Attachment Content-Type Size
strict.text_soundex.patch text/plain 868 bytes
soundex.difference-2.patch text/plain 6.4 KB

From: Neil Conway <neilc(at)samurai(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: add soundex difference function to
Date: 2005-01-25 07:38:12
Message-ID: 1106638692.9525.9.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Tue, 2005-01-25 at 02:26 -0500, Kris Jurka wrote:
> Yes, it should, and even more importantly strict because it crashes when
> called with null inputs. I copied this off the adjacent entry without
> thinking about it. So currently SELECT text_soundex(NULL); crashes the
> server.

Ah, good catch. I remember checking all the builtin functions for
crashes on NULL input; it would be worth doing the same for contrib/.

Barring any objections, I'll apply the full patch to HEAD and the crash
fix to REL8_0_STABLE and REL7_4_STABLE tomorrow.

-Neil


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: add soundex difference function to contrib/fuzzystrmatch
Date: 2005-01-25 11:02:53
Message-ID: 41F6275D.9020908@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Kris Jurka wrote:

>The attached patch implements the soundex difference function which
>compares two strings' soundex values for similarity.
>
>
>
>

ISTM that given how soundex-specific this function is it should have a
less generic name than "difference".

soundex_difference maybe?

cheers

andrew


From: Kris Jurka <books(at)ejurka(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: add soundex difference function to contrib/fuzzystrmatch
Date: 2005-01-25 17:47:56
Message-ID: Pine.BSO.4.56.0501251245310.29078@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Tue, 25 Jan 2005, Andrew Dunstan wrote:

> ISTM that given how soundex-specific this function is it should have a
> less generic name than "difference".
>
> soundex_difference maybe?
>

Maybe, but difference is the name used by ms-sql, and it is also has
the same meaning in the ODBC/JDBC escape sequence
{fn difference('a','b') }

Kris Jurka


From: Neil Conway <neilc(at)samurai(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: add soundex difference function to contrib/fuzzystrmatch
Date: 2005-01-26 08:28:03
Message-ID: 41F75493.9000103@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Kris Jurka wrote:
> I've attached two new patches. One revising my original patch to
> make the function creations consistent and the other to just fix the
> problem in the existing code (which should be backported as far as people
> would like to).

Full patch applied to HEAD, fix for STRICT applied to 8.0, 7.4, 7.3 and 7.2

Thanks for the patches.

-Neil