Re: request a new feature in fuzzystrmatch

From: Liming Hu <dawninghu(at)gmail(dot)com>
To: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: request a new feature in fuzzystrmatch
Date: 2013-05-18 06:37:12
Message-ID: CAE-MfPusWdCJ5a5_vn5M2xr_sc2ed2n6=E6oDLaRr5w8iSLS+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

On Fri, May 17, 2013 at 11:13 PM, Atri Sharma <atri(dot)jiit(at)gmail(dot)com> wrote:
>
>
> Sent from my iPad
>
> On 18-May-2013, at 11:23, Liming Hu <dawninghu(at)gmail(dot)com> wrote:
>
>> On Fri, May 17, 2013 at 10:21 PM, Atri Sharma <atri(dot)jiit(at)gmail(dot)com> wrote:
>>>
>>>
>>> Sent from my iPad
>>>
>>> On 18-May-2013, at 10:41, Liming Hu <dawninghu(at)gmail(dot)com> wrote:
>>>
>>>> On Fri, May 17, 2013 at 9:39 PM, Atri Sharma <atri(dot)jiit(at)gmail(dot)com> wrote:
>>>>>
>>>>>
>>>>> Sent from my iPad
>>>>>
>>>>> On 18-May-2013, at 10:00, Liming Hu <dawninghu(at)gmail(dot)com> wrote:
>>>>>
>>>>>> On 5/17/2013 9:10 PM, Atri Sharma wrote:
>>>>>>> On Sat, May 18, 2013 at 9:27 AM, Liming Hu <dawninghu(at)gmail(dot)com> wrote:
>>>>>>>> On 5/17/2013 12:39 PM, Liming Hu wrote:
>>>>>>>>> On Fri, May 17, 2013 at 12:06 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
>>>>>>>>>>> Can we add Levenshtein-Damerau edit distance since it is used in
>>>>>>>>>>> spelling checker
>>>>>>>>>>> instead of levenshtein edit distance?
>>>>>>>>>> Patches welcome! You, too, can be a PostgreSQL contributor.
>>>>>>>>>>
>>>>>>>>>> However, you will need to preserve the ability of users to use the old
>>>>>>>>>> levenshtien algorithm as well, for backwards-compatibility. Shouldn't
>>>>>>>>>> be hard, just add a new function called levenshtiend().
>>>>>>>>> I am working on it, I will make it this weekend project.
>>>>>>>>
>>>>>>>> I have done that. and put the code at github:
>>>>>>>> https://github.com/liminghu/fuzzystrmatch
>>>>>>>>
>>>>>>>> liming(at)liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>>>>>>>> sudo cp fuzzystrmatch.so
>>>>>>>> /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so
>>>>>>>> liming(at)liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>>>>>>>> sudo /etc/init.d/postgresql restart
>>>>>>>>
>>>>>>>> * Restarting PostgreSQL 9.1 database server
>>>>>>>>
>>>>>>>> [ OK ]
>>>>>>>>
>>>>>>>>
>>>>>>>> select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
>>>>>>>> CREATE EXTENSION fuzzystrmatch;
>>>>>>>>
>>>>>>>> ********** Error **********
>>>>>>>>
>>>>>>>> ERROR: could not load library
>>>>>>>> "/usr/lib/postgresql/9.1/lib/fuzzystrmatch.so":
>>>>>>>> /usr/lib/postgresql/9.1/lib/fuzzystrmatch.so: undefined symbol:
>>>>>>>> damerau_levenshtein_internal_noncompatible
>>>>>>>>
>>>>>>>> Any one can help me on this? Thanks.
>>>>>>> The system is not able to find the required library, and I dont think
>>>>>>> using cp to place the library is a very good idea.Did you run Make
>>>>>>> Install after you added your work in the Makefile?
>>>>>>
>>>>>> I did not run make install. I am running a stable postgresql in my laptop, I do not
>>>>>> want to reinstall everything, just want to try this contribution. I am afraid
>>>>>> reinstall it will destroy my configurations, and databases, just do not want to mess up.
>>>>>> did you see any thing wrong:
>>>>>> https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--1.0.sql
>>>>>> https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch--unpackaged--1.0.sql
>>>>>> https://github.com/liminghu/fuzzystrmatch/blob/master/fuzzystrmatch.c
>>>>>> https://github.com/liminghu/fuzzystrmatch/blob/master/dameraulevenshtein.c
>>>>>> https://github.com/liminghu/fuzzystrmatch/blob/master/
>>>>>
>>>>>
>>>>>
>>>>> You need not reinstall your entire database for installing/re installing an extension.Running make install from the extension's directory(after placing it in /contrib of a postgres database source directory) will install the extension in your current database without breaking anything.
>>>>
>>>> You mean:
>>>> liming(at)liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>>>> make install
>>>> ?
>>>
>>> Yes,although,I would run make clean before running make install,just for ensuring that all runs well.
>>
>> liming(at)liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>> sudo make clean
>> rm -f fuzzystrmatch.so libfuzzystrmatch.a
>> rm -f fuzzystrmatch.o dmetaphone.o
>> liming(at)liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>> sudo make install
>> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
>> -Wdeclaration-after-statement -Wendif-labels -Wformat-security
>> -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -I. -I.
>> -I../../src/include -D_GNU_SOURCE -c -o fuzzystrmatch.o
>> fuzzystrmatch.c
>> In file included from fuzzystrmatch.c:250:0:
>> dameraulevenshtein.c: In function ‘damerau_levenshtein_internal’:
>> dameraulevenshtein.c:290:57: warning: unused variable ‘trans’
>> [-Wunused-variable]
>> dameraulevenshtein.c:328:57: warning: unused variable ‘trans’
>> [-Wunused-variable]
>> In file included from fuzzystrmatch.c:253:0:
>> dameraulevenshtein.c: In function ‘damerau_levenshtein_less_equal_internal’:
>> dameraulevenshtein.c:290:57: warning: unused variable ‘trans’
>> [-Wunused-variable]
>> dameraulevenshtein.c:328:57: warning: unused variable ‘trans’
>> [-Wunused-variable]
>> dameraulevenshtein.c: In function ‘dameraulevenshtein_with_costs_noncompatible’:
>> dameraulevenshtein.c:480:9: warning: ISO C90 forbids mixed
>> declarations and code [-Wdeclaration-after-statement]
>> dameraulevenshtein.c:494:10: warning: ISO C90 forbids mixed
>> declarations and code [-Wdeclaration-after-statement]
>> fuzzystrmatch.c: In function ‘damerau_levenshtein_with_costs_noncompatible’:
>> fuzzystrmatch.c:266:2: warning: implicit declaration of function
>> ‘damerau_levenshtein_internal_noncompatible’
>> [-Wimplicit-function-declaration]
>> fuzzystrmatch.c: At top level:
>> dameraulevenshtein.c:40:12: warning: ‘dameraulevenshtein_internal’
>> declared ‘static’ but never defined [-Wunused-function]
>> dameraulevenshtein.c:37:12: warning:
>> ‘dameraulevenshtein_less_equal_internal’ declared ‘static’ but never
>> defined [-Wunused-function]
>> dameraulevenshtein.c:464:12: warning:
>> ‘dameraulevenshtein_with_costs_noncompatible’ defined but not used
>> [-Wunused-function]
>> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
>> -Wdeclaration-after-statement -Wendif-labels -Wformat-security
>> -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -I. -I.
>> -I../../src/include -D_GNU_SOURCE -c -o dmetaphone.o dmetaphone.c
>> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
>> -Wdeclaration-after-statement -Wendif-labels -Wformat-security
>> -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -shared
>> -o fuzzystrmatch.so fuzzystrmatch.o dmetaphone.o -L../../src/port
>> -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags
>> /bin/mkdir -p '/usr/local/pgsql/lib'
>> /bin/mkdir -p '/usr/local/pgsql/share/extension'
>> /bin/mkdir -p '/usr/local/pgsql/share/extension'
>> /bin/sh ../../config/install-sh -c -m 755 fuzzystrmatch.so
>> '/usr/local/pgsql/lib/fuzzystrmatch.so'
>> /bin/sh ../../config/install-sh -c -m 644 ./fuzzystrmatch.control
>> '/usr/local/pgsql/share/extension/'
>> /bin/sh ../../config/install-sh -c -m 644 ./fuzzystrmatch--1.0.sql
>> ./fuzzystrmatch--unpackaged--1.0.sql
>> '/usr/local/pgsql/share/extension/'
>> liming(at)liming-UX31A:~/Downloads/postgresql-9.1.9/contrib/fuzzystrmatch$
>>
>>
>> After that:
>>
>> CREATE EXTENSION fuzzystrmatch;
>> select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
>>
>>
>>
>>
>> ERROR: function dameraulevenshteinnocompatible(unknown, unknown,
>> integer, integer, integer, integer) does not exist
>> LINE 1: select dameraulevenshteinnocompatible('cta', 'cat',1,1,1,1);
>> ^
>> HINT: No function matches the given name and argument types. You
>> might need to add explicit type casts.
>>
>>
>> ********** Error **********
>>
>> ERROR: function dameraulevenshteinnocompatible(unknown, unknown,
>> integer, integer, integer, integer) does not exist
>> SQL state: 42883
>> Hint: No function matches the given name and argument types. You might
>> need to add explicit type casts.
>> Character: 8
>>
>>
>>
>
> Ok,so now, we are in issues with the code and possibly, the configurations.
>
> First up, I would fix the warnings
> that are being generated while compiling.Those may lead to hard to detect errors later on.
>>
>
> It seems that the functions you added are not being created in the database.Are you sure that you have modified the .SQL files correctly to create you functions as well,and that you are using the correct SQL files while installing?
>
> Does this happen only with dameraulevenshteinnocompatible, or with every function that you added? Have you tried using one of the original functions of fuzzystrmatch,to ensure that the original functionalities are still working?
>

it seems the make install command will copy fuzzystrmatch.so to:
liming(at)liming-UX31A:/usr/local/pgsql/lib$ ls -la
total 48
drwxr-xr-x 2 root root 4096 May 17 23:14 .
drwxr-xr-x 4 root root 4096 May 17 22:39 ..
-rwxr-xr-x 1 root root 40640 May 17 23:14 fuzzystrmatch.so

liming(at)liming-UX31A:/usr/local/pgsql/share/extension$ ls -la
total 28
drwxr-xr-x 2 root root 4096 May 17 23:14 .
drwxr-xr-x 3 root root 4096 May 17 22:39 ..
-rw-r--r-- 1 root root 2250 May 17 22:48 fuzzystrmatch--1.0.sql
-rw-r--r-- 1 root root 2250 May 17 23:14 fuzzystrmatch--1.1.sql
-rw-r--r-- 1 root root 175 May 17 23:14 fuzzystrmatch.control
-rw-r--r-- 1 root root 1945 May 17 22:48 fuzzystrmatch--unpackaged--1.0.sql
-rw-r--r-- 1 root root 1945 May 17 23:14 fuzzystrmatch--unpackaged--1.1.sql

instead of:

liming(at)liming-UX31A:/usr/local/pgsql/lib$ ls -la
/usr/lib/postgresql/9.1/lib/fuzzystrmatch.so
-rw-r--r-- 1 root root 30520 May 17 19:50
/usr/lib/postgresql/9.1/lib/fuzzystrmatch.so

That's the problem.

> Regards,
>
> Atri

--
Liming Hu
cell: (435)-512-4190
Seattle Washington

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Atri Sharma 2013-05-18 06:44:27 Re: request a new feature in fuzzystrmatch
Previous Message Atri Sharma 2013-05-18 06:13:00 Re: request a new feature in fuzzystrmatch

Browse pgsql-www by date

  From Date Subject
Next Message Atri Sharma 2013-05-18 06:44:27 Re: request a new feature in fuzzystrmatch
Previous Message Atri Sharma 2013-05-18 06:13:00 Re: request a new feature in fuzzystrmatch