Thread: add soundex difference function to contrib/fuzzystrmatch

add soundex difference function to contrib/fuzzystrmatch

From
Kris Jurka
Date:
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

Re: add soundex difference function to

From
Neil Conway
Date:
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



Re: add soundex difference function to contrib/fuzzystrmatch

From
Kris Jurka
Date:

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

Re: add soundex difference function to

From
Neil Conway
Date:
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



Re: add soundex difference function to contrib/fuzzystrmatch

From
Andrew Dunstan
Date:

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

Re: add soundex difference function to contrib/fuzzystrmatch

From
Kris Jurka
Date:

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

Re: add soundex difference function to contrib/fuzzystrmatch

From
Neil Conway
Date:
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