Re: contrib/levenshtein() has a bug? - Mailing list pgsql-general

From Tom Lane
Subject Re: contrib/levenshtein() has a bug?
Date
Msg-id 5739.1159478366@sss.pgh.pa.us
Whole thread Raw
In response to contrib/levenshtein() has a bug?  (Ben <bench@silentmedia.com>)
Responses Re: contrib/levenshtein() has a bug?  (Ben <bench@silentmedia.com>)
List pgsql-general
Ben <bench@silentmedia.com> writes:
> The levenshtein function from contrib/fuzzystrmatch.sql has a max arg
> length of 255. OK, that's cool. But check this out:

> mbrainz_db=> select max(length(name)) from public.track;
>   max
> -----
>   255
> (1 row)

> mbrainz_db=> select levenshtein(name,'foo') from public.track;
> ERROR:  argument exceeds max length: 255

> That seems odd.

length() measures in characters whereas the limit in question is being
enforced in bytes.  You got any multibyte characters in there?

(It looks to me like levenshtein() is utterly non-multibyte-aware,
which is probably a bug in itself.)

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: contrib/levenshtein() has a bug?
Next
From: Geoffrey
Date:
Subject: Re: continued segmentation fault