Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0NVY-00B66H-6W for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Oct 2024 16:01:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t0NVV-00EZjL-Vs for pgsql-bugs@arkaria.postgresql.org; Mon, 14 Oct 2024 16:01:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0NVV-00EZjD-Na for pgsql-bugs@lists.postgresql.org; Mon, 14 Oct 2024 16:01:18 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0NVQ-0011vv-Qf for pgsql-bugs@lists.postgresql.org; Mon, 14 Oct 2024 16:01:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 49EG13Tl3737495; Mon, 14 Oct 2024 12:01:04 -0400 From: Tom Lane To: bjdev.gthb@laposte.net cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18654: From fuzzystrmatch, levenshtein function with costs parameters produce incorrect results In-reply-to: <18654-c09f568d3ba6dfcd@postgresql.org> References: <18654-c09f568d3ba6dfcd@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 14 Oct 2024 09:14:50 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3737493.1728921663.1@sss.pgh.pa.us> Date: Mon, 14 Oct 2024 12:01:03 -0400 Message-ID: <3737494.1728921663@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > But if we use this function with parameters other than 1 (the default) the > result is incorrect > SELECT levenshtein('horses','shorse',1,1,1) => 2 (correct) > SELECT levenshtein('horses','shorse',100,10,1) => 101 (INCORRECT) > The correct result is 6 (all the letter have to be substitute and it's not > possible to have a lower score with others operations) Hmm, works for me: u8=# create extension fuzzystrmatch; CREATE EXTENSION u8=# SELECT levenshtein('horses','shorse',1,1,1); levenshtein ------------- 2 (1 row) u8=# SELECT levenshtein('horses','shorse',100,10,1); levenshtein ------------- 6 (1 row) I confess bafflement about why you're getting wrong answers. You seem to be using a slightly out of date Postgres, but none of this code has changed meaningfully since about 2016. Maybe you hit a compiler bug? Where did you get this copy of Postgres from --- or if you built it yourself, what build options did you use? regards, tom lane