add soundex difference function to contrib/fuzzystrmatch

Started by Kris Jurkaalmost 22 years ago7 messagespatches
Jump to latest
#1Kris Jurka
books@ejurka.com

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

Attachments:

soundex.difference.patchtext/plain; charset=US-ASCII; name=soundex.difference.patchDownload+48-9
#2Neil Conway
neilc@samurai.com
In reply to: Kris Jurka (#1)
Re: add soundex difference function to

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

#3Kris Jurka
books@ejurka.com
In reply to: Neil Conway (#2)
Re: add soundex difference function to contrib/fuzzystrmatch

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

Attachments:

strict.text_soundex.patchtext/plain; charset=US-ASCII; name=strict.text_soundex.patchDownload+2-2
soundex.difference-2.patchtext/plain; charset=US-ASCII; name=soundex.difference-2.patchDownload+70-35
#4Neil Conway
neilc@samurai.com
In reply to: Kris Jurka (#3)
Re: add soundex difference function to

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

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Kris Jurka (#1)
Re: add soundex difference function to contrib/fuzzystrmatch

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

#6Kris Jurka
books@ejurka.com
In reply to: Andrew Dunstan (#5)
Re: add soundex difference function to contrib/fuzzystrmatch

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

#7Neil Conway
neilc@samurai.com
In reply to: Kris Jurka (#3)
Re: add soundex difference function to contrib/fuzzystrmatch

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