Re: bug: fuzzystrmatch levenshtein is wrong

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: marcin mank <marcin(dot)mank(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bug: fuzzystrmatch levenshtein is wrong
Date: 2009-12-09 02:04:02
Message-ID: 603c8f070912081804y16268436t3e1b12d7d2ac4bf4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 7, 2009 at 8:33 AM, marcin mank <marcin(dot)mank(at)gmail(dot)com> wrote:
> The current behavior of levenshtein(text,text,int,int,int) is wrong. Consider:
>
> leki_dev=# select levenshtein('','a',2,4,5);
>  levenshtein
> -------------
>           1
> (1 row)
>
>
> leki_dev=# select levenshtein('a','',2,4,5);
>  levenshtein
> -------------
>           1
> (1 row)
>
>
> leki_dev=# select levenshtein('aa','a',2,4,5);
>  levenshtein
> -------------
>           1
> (1 row)
>
>
> leki_dev=# select levenshtein('a','aa',2,4,5);
>  levenshtein
> -------------
>           1
> (1 row)
>
> versus (after patch)
>
> postgres=# select levenshtein('','a',2,4,5);
>  levenshtein
> -------------
>           2
> (1 row)
>
> postgres=# select levenshtein('a','',2,4,5);
>  levenshtein
> -------------
>           4
> (1 row)
>
> postgres=# select levenshtein('aa','a',2,4,5);
>  levenshtein
> -------------
>           4
> (1 row)
>
> postgres=# select levenshtein('a','aa',2,4,5);
>  levenshtein
> -------------
>           2
> (1 row)
>
> patch attached.

I cannot get this patch to apply for anything. All 4 hunks fail, both
on HEAD and on the the pre-8.4-pgindent version of fuzzystrmatch.c.
Either I'm doing something wrong here, or there's something wrong with
this patch file.

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2009-12-09 02:08:38 Re: bug: fuzzystrmatch levenshtein is wrong
Previous Message Fujii Masao 2009-12-09 01:51:58 Re: Streaming replication, some small issues